[Solved] Re-define template in $this->partials($this->config() ... possible?
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!
Always add your TYPO3, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
[Solved] Re-define template in $this->partials($this->config() ... possible?
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:
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:
pointing to a different template within the
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
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
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; ?>
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.
-
- Posts: 2
- Joined: 20 Apr 2017, 11:40
Re: Re-define template in $this->partials($this->config() ... possible?
What exactly does not work? Is the template not loaded?
Re: Re-define template in $this->partials($this->config() ... possible?
The same template that is defined in the Typoscript Configuration is displayed again. Not the new one that is refered to in the loop.
Re: Re-define template in $this->partials($this->config() ... possible?
I have troubles understanding the "$this->partials($this->config" logic.
E.g., when I take this snippet that is responsible for displaying the media:
and I assign it a non existing template:
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:
nothing spectacular happens, no error, everything is displayed using the template assigned via TS.
Why does the second scenario not throw an error?
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' ) )
) . '<!--'; ?>
Code: Select all
'common/partials/this-template-does-not-exist'
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
[
Why does the second scenario not throw an error?
Re: Re-define template in $this->partials($this->config() ... possible?
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, give us a star
If you like Aimeos, give us a star
Re: Re-define template in $this->partials($this->config() ... possible?
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.
In my case, to stay flexible, it seems to be better to override templates directly in the php `$hits->partial($this->config ...` functions.