[Solved] What can "params" really do?

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] What can "params" really do?

Post by rowild » 20 Oct 2020, 22:18

In the filter tree templates there is this code section:

Code: Select all


<?php if( count( $item->getChildren() ) > 0 ) : ?>
	<?= $this->partial(
		$this->config(
			'client/html/catalog/filter/partials/tree',
			'catalog/filter/navigation/tree-partial-standard'
		),
		[
			'nodes' => $item->getChildren(),
			'path' => $this->get( 'path', map() ),
			'level' => $this->get( 'level', 0 ) + 1,
			'params' => $this->get( 'params', [] ).     // <== how can I pass on stuff? 
		]
	); ?>
<?php endif; ?>

In my setup there is a property, which I can get via

Code: Select all

$item->get['css-class']
Can i use the params attribute to pass it on to the template? And if so, how?

(As an object like
{ "cssClass": $item->get['css-class'] }
would be great...)
Last edited by rowild on 31 Oct 2020, 08:56, edited 1 time in total.

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

Re: What can "params" really do?

Post by aimeos » 21 Oct 2020, 10:08

Don't use the "params" argument for passing additional data to the partial because "params" is used to build the URLs.
Instead, you can pass additional data using an additional arbitrary name, e.g.:

Code: Select all

	<?= $this->partial(
		$this->config(
			'client/html/catalog/filter/partials/tree',
			'catalog/filter/navigation/tree-partial-standard'
		),
		[
			'nodes' => $item->getChildren(),
			'path' => $this->get( 'path', map() ),
			'level' => $this->get( 'level', 0 ) + 1,
			'params' => $this->get( 'params', [] ),
			'css' => $item->getConfig()
		]
	); ?>
Then, the data will be available in the partial using

Code: Select all

$this->get( 'css', [] );
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

rowild

Re: What can "params" really do?

Post by rowild » 31 Oct 2020, 08:56

Thank you!!

Post Reply