Two different templates for one component
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Two different templates for one component
Hello! I need to implement two or more different views of catalog/filter component with same functionality.
As i found in docs:
Seems like <variant> is what i need, but i don't sure about that and don't understand how to use.
As i found in docs:
Code: Select all
<component type>/<component name>/[<subpart name>[-<sub-subpart name>]-]{body,header}-<variant>.php
Re: Two different templates for one component
It depends a bit on your application environment (Laravel, Symfony or TYPO3).
In Laravel/Symfony, you need to set the configuration for the variant template in the controller action, e.g.:
https://aimeos.org/docs/2020.x/config/c ... plate-body
In TYPO3, you can configure the template per plugin instance in the TS-Config field.
In Laravel/Symfony, you need to set the configuration for the variant template in the controller action, e.g.:
https://aimeos.org/docs/2020.x/config/c ... plate-body
In TYPO3, you can configure the template per plugin instance in the TS-Config field.
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: Two different templates for one component
Sorry, forgot to write, i use Laravel.
Oh, it's really difficult to understand docs. But i tried and it's now work or i doing something wrong.
Seems like that not what i need, but i'll tried anyway.
I added:
1. shop.php
2. Create copy of tree-body-standard.php with name tree-body-menu.php and some changes
3. Added <?= $aibody['catalog/tree'] ?? '' ?> where i need in Blade template file between section
But there is no changes in frontend at all.
As i understand, this will replace catalog/tree/template in whole site, but i need to save original one template and create new one with same functionality but with another template. Is that what i need?
Oh, it's really difficult to understand docs. But i tried and it's now work or i doing something wrong.
Seems like that not what i need, but i'll tried anyway.
I added:
1. shop.php
Code: Select all
'client' => [
'html' => [
'catalog' => [
'filter' => [
'cache' => false,
'tree' => [
'standard' => [
'template-body' => 'catalog/filter/tree-body-menu',
],
],
],
],
],
],
3. Added <?= $aibody['catalog/tree'] ?? '' ?> where i need in Blade template file between section
But there is no changes in frontend at all.
As i understand, this will replace catalog/tree/template in whole site, but i need to save original one template and create new one with same functionality but with another template. Is that what i need?
Last edited by Starpag on 19 Nov 2020, 21:00, edited 1 time in total.
Re: Two different templates for one component
I just want to implement such simple think like Megamenu to header.
Something like this
To implement this as i understand i need catalog/tree, but seems like it's overpowered for my case. Maybe i'm going wrong way?
Something like this
To implement this as i understand i need catalog/tree, but seems like it's overpowered for my case. Maybe i'm going wrong way?
Re: Two different templates for one component
Your steps are correct, this should use your alternative template for the tree part of the catalog/filter component and the catalog/tree component provided you placed your template in your own extension at ./ext/<yourext>/client/html/templates/catalog/filter/tree-body-menu.php
Check, if it's not cached resp. disable caching for development:
https://github.com/aimeos/aimeos-laravel#hints
If it doesn't work for whatever reason, try to save your own template as
./ext/<yourext>/client/html/templates/catalog/filter/tree-body-standard.php
This will overwrite the default template.
Check, if it's not cached resp. disable caching for development:
https://github.com/aimeos/aimeos-laravel#hints
If it doesn't work for whatever reason, try to save your own template as
./ext/<yourext>/client/html/templates/catalog/filter/tree-body-standard.php
This will overwrite the default template.
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: Two different templates for one component
For some reasons it's work if i named it tree-body-standard.php, but tree-body-menu.php not work.
Cache is disabled, yes. I will try further.
But as I understand it enforce all <?= $aibody['catalog/tree'] ?? '' ?> in whole site used new template, but how to determinate with <?= $aibody['catalog/tree'] ?? '' ?> which Variant of template -menu or -menu2 in different places?
Cache is disabled, yes. I will try further.
But as I understand it enforce all <?= $aibody['catalog/tree'] ?? '' ?> in whole site used new template, but how to determinate with <?= $aibody['catalog/tree'] ?? '' ?> which Variant of template -menu or -menu2 in different places?
Re: Two different templates for one component
Then, your configuration in your ./config/shop.php file isn't used. Can you please post your file (without credentials)?
It's not possible to distingusih in the Blade template which variant should be used. This can only be done by setting the configuration in the controller action.
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: Two different templates for one component
Here my shop.php
Code: Select all
<?php
return [
'apc_enabled' => false, // enable for maximum performance if APCu is availalbe
'apc_prefix' => 'aimeos:', // prefix for caching config and translation in APCu
'pcntl_max' => 4, // maximum number of parallel command line processes when starting jobs
'routes' => [
],
'page' => [
// Docs: https://aimeos.org/docs/Laravel/Adapt_pages
// Hint: catalog/filter is also available as single 'catalog/tree', 'catalog/search', 'catalog/attribute'
'account-index' => ['account/profile', 'account/review', 'account/subscription', 'account/history', 'account/favorite', 'account/watch', 'basket/mini', 'catalog/session', 'locale/select'],
'basket-index' => ['basket/bulk', 'basket/standard', 'basket/related'],
'catalog-count' => ['catalog/count'],
'catalog-detail' => ['basket/mini', 'catalog/stage', 'catalog/detail', 'catalog/session', 'locale/select'],
'catalog-home' => ['basket/mini', 'catalog/home', 'locale/select', 'catalog/tree'],
'catalog-list' => ['basket/mini', 'catalog/filter', 'catalog/lists', 'locale/select'],
'catalog-stock' => ['catalog/stock'],
'catalog-suggest' => ['catalog/suggest'],
'catalog-tree' => ['basket/mini', 'catalog/filter', 'catalog/stage', 'catalog/lists', 'locale/select'],
'checkout-confirm' => ['checkout/confirm'],
'checkout-index' => ['checkout/standard'],
'checkout-update' => ['checkout/update'],
],
'admin' => [],
'client' => [
'html' => [
'basket' => [
'cache' => [
// 'enable' => false, // Disable basket content caching for development
],
],
'catalog' => [
'filter' => [
'cache' => false,
'tree' => [
'standard' => [
'template-body' => 'catalog/filter/tree-body-menu',
],
],
],
],
'common' => [
'template' => [
// 'baseurl' => public_path( 'packages/aimeos/shop/themes/elegance' ),
],
],
'catalog' => [
'selection' => [
'type' => [
'color' => 'radio',
'length' => 'radio',
'width' => 'radio',
],
],
],
],
],
'controller' => [],
'i18n' => [],
'madmin' => [
'cache' => [
'manager' => [
'name' => 'None', // Disable caching for development
],
],
'log' => [
'manager' => [
'standard' => [
'loglevel' => 7, // Enable debug logging into madmin_log table
],
],
],
],
'mshop' => [],
'command' => [],
'frontend' => [],
'backend' => [],
];
How can i do this? This is exactly what i want.This can only be done by setting the configuration in the controller action.
Re: Two different templates for one component
These are the steps you need:
- Create your own Laravel controller in your ./app/Http/Controllers/ directory
- Copy the action from the Aimeos controller you want to have a different configuration, e.g. https://github.com/aimeos/aimeos-larave ... hp#L86-L96
- Use this to set the modified configuration:
- Add a route with your own controller that replaces the Aimeos standard route, e.g. one of https://github.com/aimeos/aimeos-larave ... #L183-L235
- Create your own Laravel controller in your ./app/Http/Controllers/ directory
- Copy the action from the Aimeos controller you want to have a different configuration, e.g. https://github.com/aimeos/aimeos-larave ... hp#L86-L96
- Use this to set the modified configuration:
Code: Select all
app('aimeos.context')->getConfig()->set('client/html/catalog/filter/tree/standard/template-body', 'catalog/filter/tree-body-menu');
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