[Solved] Re-define template in $this->partials($this->config() ... possible?

Questions around the TYPO3 integration and plugins
Forum rules
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
rowild

[Solved] Re-define template in $this->partials($this->config() ... possible?

Post by rowild » 16 Oct 2020, 08:13

I would like to override the filter tree components. In a first step, the templates are overridden in the Typoscript Configuration field of the "aimeos__catalog-tree" extension:

Code: Select all

client.html.catalog.filter.tree.standard.template-body = catalog/filter/tree-body-startpage
client.html.catalog.filter.partials.tree = catalog/filter/tree-partial-startpage
That works fine. Now I would like to use a different template for all categories of level 1. I thought I could do that by manipulating this art of the code:

Code: Select all

 // tree-partial-startpage.php, around line 125ff
 
<?php if( count( $item->getChildren() ) > 0 ) : ?>
	<?= $this->partial(
		$this->config( 
			'client/html/catalog/filter/partials/tree', 
			'catalog/filter/tree-partial-startpage-categories' ),  // <== use new partial in levels > 0?
		[
			'nodes' => $item->getChildren(),
			'path' => $this->get( 'path', map() ),
			'level' => $this->get( 'level', 0 ) + 1,
			'params' => $this->get( 'params', [] )
		]
	); ?>
<?php endif; ?>
pointing to a different template within the

Code: Select all

`$this->config($this->partial-> ...

section.

Unfortunately, this does not work.
What would be the proper way to do that? If it is possible at all?

Thank you!

TYPO3 9.5.22, aimeos 2020.7.5, php 7.3.23
Last edited by rowild on 20 Oct 2020, 16:57, edited 1 time in total.

JonasEberleDmind
Posts: 2
Joined: 20 Apr 2017, 11:40

Re: Re-define template in $this->partials($this->config() ... possible?

Post by JonasEberleDmind » 16 Oct 2020, 11:46

What exactly does not work? Is the template not loaded?

rowild

Re: Re-define template in $this->partials($this->config() ... possible?

Post by rowild » 16 Oct 2020, 12:02

The same template that is defined in the Typoscript Configuration is displayed again. Not the new one that is refered to in the loop.

rowild

Re: Re-define template in $this->partials($this->config() ... possible?

Post by rowild » 16 Oct 2020, 12:32

I have troubles understanding the "$this->partials($this->config" logic.

E.g., when I take this snippet that is responsible for displaying the media:

Code: Select all

<?= '-->'
. $this->partial(
	$this->config( 
		'client/html/common/partials/media', 
		'common/partials/media-standard' 
	),
	array( 'item' => $mediaItem, 'boxAttributes' => array( 'class' => 'media-item' ) )
) . '<!--'; ?>
and I assign it a non existing template:

Code: Select all

'common/partials/this-template-does-not-exist'
 
then an error is thrown in the FE (one of those "An unrecovereable error...").

But when I assign a wrong template in the loop section of the tree filter:

Code: Select all

<?php if( count( $item->getChildren() ) > 0 ) : ?>
	<?= $this->partial(
		$this->config( 
			'client/html/catalog/filter/partials/tree', 
			'catalog/filter/template-does-not-exist' ),  // <== wrong template here
		[
nothing spectacular happens, no error, everything is displayed using the template assigned via TS.

Why does the second scenario not throw an error?

User avatar
aimeos
Administrator
Posts: 8239
Joined: 01 Jan 1970, 00:00

Re: Re-define template in $this->partials($this->config() ... possible?

Post by aimeos » 16 Oct 2020, 15:39

You've configured "client/html/catalog/filter/partials/tree" elsewhere so the default value in the second parameter isn't used.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rowild

Re: Re-define template in $this->partials($this->config() ... possible?

Post by rowild » 20 Oct 2020, 16:57

I can confirm that once a template override is done in TypoScript, a "default" is defined. And that means that the respective php functions won't reassign a new template anymore.

In my case, to stay flexible, it seems to be better to override templates directly in the php `$hits->partial($this->config ...` functions.

Post Reply