I wonder if anybody could point me in the right direction?
I am trying to add the category SEO title to each of the categories in the sidemenu. I know I need to be amending the in the menu_items.tpl file and I have tried to use title=“{$page_title}” to no avail. I know I am missing something glaringly obvious, but cant see what. Is the variable I am using incorrect or does it need calling to the page in some way?
Thank you
So you're trying to add a 'Title' class to the categories URL to have the link like this:
Category Name
You would need to add to the in the appropriate file, depending on which your template uses:
title="{$category.category}"
Thanks for your reply !
I am actually trying to add the Category SEO Title (which is $page_title) and not the Category Page Title. I know the file I want to add it to is menu_items.tpl found in view/categories/componenets.
I am pretty sure $page_title is correct as it is referrenced in index.tpl in root, it feeds the SEO title into the .
Any help would be gratefully received.
Here is the view/categories/componenet/menu_items.tpl file - I have highlighted the part I know I need to add to:
{strip}
{assign var=“foreach_name” value=“cats_$cid”}
{foreach from=$items item=“category” name=$foreach_name}
{if $category.subcategories}
{include file="views/categories/components/menu_items.tpl" items=$category.subcategories separated=true submenu=true cid=$category.category_id}
{/if}
{$category.category}
{if $separated && !$smarty.foreach.$foreach_name.last}
{/if}
{/foreach}
{/strip}
I suppose you mean the 'Page Title' value found under SEO/Meta data?
{$page_title} is correct for this value. Is the 'a href' still generating the title tags as empty, eg:
Yes, StellaBytes that was what I was referring to - the category SEO title and not the category page title.
If I use $page_title then nothing comes through if I put $location_data.page_title then I get an SEO title but unfortunately the one for the page that you are on and not the one that relates to the category menu item link. I am guessing I need to use the foreach function, but I have no idea how to do that!
Any help would be gratefully received
The controller for categories (controllers/customer/categories.php) builds the page title like so:
// If page title for this category is exist than assign it to template
if (!empty($category_data['page_title'])) {
$view->assign('page_title', $category_data['page_title']);
}
Therefore you should be able to use:
{$category_data.page_title}
If that doesn't work, pull it from a function which does access that value such as (i think) the category breadcrumbs, something like this should work:
{math assign="get_category" equation="x-2" x=$breadcrumbs|@count}
{$category.category}
Not tested, but you get the idea.
Thanks StellarBytes.
I think {$category_data.page_title} is the right way forward, however when I tested that before it just gives me the SEO page title for the active current page and not the link category. I am convinced somehow I have to include the foreach for the page_title into the loop some how, but I am not sure how within this file view/categories/componenet/menu_items.tpl.
If you look at our website www.puppypax.co.uk it is the links to the departments you can see on the left hand side of the page that we want to add the title to.
{$category_data.page_title}
This is 100% correct for V2.2.4 - unfortunately I don't have access to your version, 2.1.4. I just tested it by adding the following to the in categories_multicolumns.tpl, like so:
{$category.category}
Which generates:
My Category
Are you positive your category menu is using menu_items.tpl?
Yes definitely using menu_items, I have checked by using customization mode, and when I change the title=“” in that file it changes on the website. categories_multicolumns goes into the central block, menu_items into a side block as its a menu.I do get some text come through when I put $category_data.page_title but it is the SEO title for the page you are currently on and not the SEO title for the menu category item.
I am very grateful for you trying to help StellarBytes