Best way to configure separate title tag?

How to configure and adapt Aimeos based shops as developer
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!
ricain
Posts: 1
Joined: 29 Nov 2020, 16:02

Best way to configure separate title tag?

Post by ricain » 29 Nov 2020, 16:15

Hi all,

I'd like to set a specific title tag (i.e. <title>) under "Texts" in the admin, so that I can configure a specific title for each product or category. This is because I'd like the page title tag to be different than the header name for some pages.

What's the best way to do this? I was reading about decorators, and wondered if that's the best way. Then I could create a new text type, and select it under the "Texts" section.

I assume I would also need to override getName()?

Thanks for your suggestions.

Aimeos version: 2020.10
PHP version: 7.4.10

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

Re: Best way to configure separate title tag?

Post by aimeos » 30 Nov 2020, 15:22

By default the category or product name is used for the HTML title tag.
To add a different text, you can add a new text type (e.g. "title") and add your title texts in the admin backend. Then, you have to change the header templates of the list and detail views:
- https://github.com/aimeos/ai-client-htm ... hp#L38-L54
- https://github.com/aimeos/ai-client-htm ... rd.php#L39

Instead of $item->getName(), you can use

Code: Select all

$item->getRefItems( 'text', 'title' )->first( $item->getName() )
This will output your title text or the name if no title text is available. That's all :-)
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

Post Reply