Decorator get no result
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Decorator get no result
Hello,
I'm trying to add new data to the view object required by the product template, (from my extension).
I create decorator path "myextension\src\Client\Html\Common\Decorator\my_product_decorator.php", and put this code in it:
and put the "config/shop.php" like this:
Now, I'm trying to get the value of the "descripto" from the decorator, so I add this in "myextension\templates\client\html\common\partials\products.php":
At the end, NO result appear. Where is the problem?
I'm trying to add new data to the view object required by the product template, (from my extension).
I create decorator path "myextension\src\Client\Html\Common\Decorator\my_product_decorator.php", and put this code in it:
Code: Select all
namespace Aimeos\Client\Html\Common\Decorator;
class my_product_decorator
extends \Aimeos\Client\Html\Common\Decorator\Base
implements \Aimeos\Client\Html\Common\Decorator\Iface
{
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
$view = parent::data( $view, $tags, $expire );
$view->descripto= 'some description';
return $view;
}
}
Code: Select all
'client' => [
'common' => [
'partials' => [
'product' => [
'decorators' => [
'global' => 'my_product_decorator',
]
]
]
],
],
],
Code: Select all
<?= $this->get( 'descripto' ) ?>
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: Decorator get no result
@Aimeos
Where is the problem?
Where is the problem?
Re: Decorator get no result
First, you should use another class name like "ProductMyproject" (replace "Myproject" by your project name).
Then, your configuration is wrong and you have to configure the decorator for a component (or all components), e.g.:
https://aimeos.org/docs/2022.x/config/c ... il/#global
Then, your configuration is wrong and you have to configure the decorator for a component (or all components), e.g.:
Code: Select all
'client' => [
'html' => [
'catalog' => [
'detail' => [
'decorators' => [
'global' => ['ProductMyproject'],
]
]
]
],
],
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
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: Decorator get no result
Thanks, I edit it, and got this error: "Aimeos\Base\View\Helper\Partial\Standard::transform(): Argument #1 ($file) must be of type string, array given"
the complete error trace:
https://flareapp.io/share/V7jLOMjm#F65
the config:
the complete error trace:
https://flareapp.io/share/V7jLOMjm#F65
the config:
Code: Select all
'html' => [
'common' => [
'partials' => [
'products' => [
'decorators' => [
'global' => ['ProductWomenTemplate'],
]
]
]
],
],
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: Decorator get no result
Unfortunately, the problem is still not resolved.
"Aimeos\Base\View\Helper\Partial\Standard::transform(): Argument #1 ($file) must be of type string, array given"
"Aimeos\Base\View\Helper\Partial\Standard::transform(): Argument #1 ($file) must be of type string, array given"
Re: Decorator get no result
Remove the configuration because it's wrong:
Code: Select all
'common' => [
'partials' => [
'products' => [
'decorators' => [
'global' => ['ProductWomenTemplate'],
]
]
]
],
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
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: Decorator get no result
Nothing changed .
I want to know is the namespace is correct? and the return value is $view?
and the aregument interface of the function is correct?
I want to know is the namespace is correct? and the return value is $view?
and the aregument interface of the function is correct?
Code: Select all
namespace Aimeos\Client\Html\Common\Decorator;
class my_product_decorator
extends \Aimeos\Client\Html\Common\Decorator\Base
implements \Aimeos\Client\Html\Common\Decorator\Iface
{
public function data( \Aimeos\Base\View\Iface $view, array &$tags = [], string &$expire = null ) : \Aimeos\Base\View\Iface
{
$view = parent::data( $view, $tags, $expire );
$view->descripto= 'some description';
return $view;
}
}
Re: Decorator get no result
Namespace is correct but your configuration is not because "common/partial/products" is now an array but it must be a string. Check again and clear the Laravel config cache if necessary.
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
- ahmed31916
- Advanced
- Posts: 148
- Joined: 14 Apr 2022, 12:15
Re: Decorator get no result
thanks for your response.
would you write a complete config for it, please! (it made me tired)is now an array but it must be a string
Re: Decorator get no result
Like written, the correct configuration is:
and remove:
If you want to use different product partials use this instead:
The template file must be in: "templates/client/html/common/partials/product-woman.php"
Code: Select all
'client' => [
'html' => [
'catalog' => [
'detail' => [
'decorators' => [
'global' => ['ProductMyproject'],
]
]
]
],
],
Code: Select all
'common' => [
'partials' => [
'products' => [
'decorators' => [
'global' => ['ProductWomenTemplate'],
]
]
]
],
Code: Select all
'common' => [
'partials' => [
'products' => 'common/partials/product-woman'
]
],
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