Best way to configure separate title tag?
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!
Best way to configure separate title tag?
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
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
Re: Best way to configure separate title tag?
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
This will output your title text or the name if no title text is available. That's all
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() )
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