Overwriting templates

Help for integrating the Laravel package
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!
KevinPopkorn
Posts: 8
Joined: 04 Feb 2019, 08:11

Overwriting templates

Post by KevinPopkorn » 04 Feb 2019, 08:18

Hi,

I'm not sure if we're getting the way we have to overwrite templates correctly, would be nice if someone could shed some light on this :) We are listing the templates we are overwriting in the shop config "client, html, <component>" array structure, but it seems to be a bit unclear on how we have to build up the array to overwrite the correct template.

For instance right now we are trying to overwrite the template:

ai-client-html/client/html/templates/catalog/filter/tree-standard.php

Which is the filter category list. How do we need to build up the array structure?
We have tried things like:

Code: Select all

   'client' => [
        'html' => [
                'filter'  => [
                    'tree'   => [
                        'standard' => [
                            'template-body' => resource_path('views/catalog/filter/tree-body-standard.php'),
                        ],
                        'partials' =>
                        [
                            'tree' => [
                                'template-body' => resource_path('views/catalog/filter/tree-standard.blade.php')
                            ]
                        ]
                    ],
                ]
             ]
But to no success, or a serious amount of hit and miss :) Can someone ellaborate a little on how the structure is supposed to be set up? We have successfully overwritten other templates with trial and error but with partials it seems to be a bit unclear naming wise.
Last edited by KevinPopkorn on 04 Feb 2019, 10:12, edited 1 time in total.

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

Re: Overwriting templates

Post by aimeos » 04 Feb 2019, 09:51

Youve' missed the "catalog" part, it's 'client/html/catalog/filter/tree/standard/template-body' and 'client/html/catalog/filter/partials/tree':
- https://github.com/aimeos/ai-client-htm ... rd.php#L98
- https://github.com/aimeos/ai-client-htm ... rd.php#L80

But you don't have to overwrite the configuration. If you copy the template you want to overwrite from:

./ext/ai-client-html/client/html/templates/catalog/filter/tree-body-standard.php
to
./ext/<yourext>/client/html/templates/catalog/filter/tree-body-standard.php

it will be found automatically and used instead of the original one :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

KevinPopkorn
Posts: 8
Joined: 04 Feb 2019, 08:11

Re: Overwriting templates

Post by KevinPopkorn » 04 Feb 2019, 10:01

Hi, thanks for the info but I apparently missed Catalog in the copy paste, it is there in our code :)

We tried adding our own ext but it still didn't seem to want to overwrite the templates, that's why we went with the configuration method instead.

Edit: We did try to use blade templates, not sure if that changes anything?

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

Re: Overwriting templates

Post by aimeos » 04 Feb 2019, 10:37

For Blade templates, you need the configuration and the extension of the Blade templates must be ".blade.php" instead of only ".php"
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

KevinPopkorn
Posts: 8
Joined: 04 Feb 2019, 08:11

Re: Overwriting templates

Post by KevinPopkorn » 04 Feb 2019, 11:52

Yes, have the .blade.php but it still refuses to overwrite the partial.
We have it working without blade, but if we try to change it to a blade it doesn't take it.

Edit: Seems there's some special magic going on as it seems to work for my colleague and on production environment but not on my machine :roll:

KevinPopkorn
Posts: 8
Joined: 04 Feb 2019, 08:11

Re: Overwriting templates

Post by KevinPopkorn » 05 Feb 2019, 14:14

This seems like a different issue entirely, my templates seem hard stuck in cache, eventhough I cleared it all through aimeos:cache etc. I don't see my colleague's adjustments that are there in files on my localhost in the rendered page.

KevinPopkorn
Posts: 8
Joined: 04 Feb 2019, 08:11

Re: Overwriting templates

Post by KevinPopkorn » 05 Feb 2019, 14:28

Update: This command saved the day :)

php artisan optimize:clear

Seems everything was stuck in cache.

Post Reply