Page 1 of 1
[SOLVED] HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 4:21 pm
by JimboDavies
I'm trying to get the Name of a Product from the Products module into the HTML title, but with limited success.
The code in my Template is currently as follows:
Code: Select all
{if isset($producttitle)}
<title>{$producttitle} | Stormforce Coaching</title>
{else}
{if isset($newstitle)}
<title>{$newstitle} | News | Stormforce Coaching</title>
{else}
<title>{title} | Stormforce Coaching</title>
{/if}
{/if}
This doesn't work for either News or Products Module. News simply displays "News | Stormforce Coaching" and any product displays "Product Page | Stormforce Coaching". These are the titles from the default display pages for these modules.
From an SEO perspective, it would be great to get the modules displaying the dynamic titles - I have done some searching but haven't been able to find anything helpful.
If anyone has any suggestions, they would be gratefully received.
Cheers,
Jimbo
Re: HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 4:38 pm
by JimboDavies
So, following reading the excellent i-can-do-this blog post
here, I've made a few changes.
The Template now contains:
Code: Select all
{if isset($alt_title_products)}
<title>{$alt_title_products} | Stormforce Coaching</title>
{else}
{if isset($alt_title_news)}
<title>{$alt_title_news} | News | Stormforce Coaching</title>
{else}
<title>{title} | Stormforce Coaching - RYA MCA HSE STCW BSAC BWS Training Courses for Sailing Powerboating Motorboating Shorebased Theory PWC JetSki Sea Survival Navigation and More</title>
{/if}
{/if}
At the bottom of my News Detail Template, I've put
Code: Select all
{assign var='alt_title_news' value=$entry->title}
At the bottom of my Product Detail Template, I've put
Code: Select all
{assign var='alt_title_products' value=$entry->title}
Still no joy unfortunately.
Re: HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 6:30 pm
by applejack
In your config file what is the process whole template option set to? It should be false.
Re: HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 7:35 pm
by JimboDavies
yes, its set to FALSE.
Re: HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 10:17 pm
by JimboDavies
I've now made it even simpler, and set just one variable in both the News Detail Template, and the Product Detail template.
My page head code now looks like this:
Code: Select all
{if isset($alt_title)}
<title>{$alt_title} | {sitename}</title>
{else}
<title>{title} | {sitename}</title>
{/if}
Still no joy unfortunately. It looks like the problem is that the variable isn't being found - I've checked the process whole template in the config.php file is set to FALSE though.
Not sure what to try next.
Re: HTML Title on Products Page set to Product Name
Posted: Fri Feb 10, 2012 11:13 pm
by maranc
Its a problem with rendering content, after </__body> section set this code:
Change {content} for {mycontent}.
Now it should be work.
Marek A.
Re: HTML Title on Products Page set to Product Name
Posted: Sat Feb 11, 2012 11:14 am
by JimboDavies
Hi Marek,
I have
in my page head, and
in the page body.
If I read you correctly, I should move the content assign into the body to fix this?
Cheers.
Re: HTML Title on Products Page set to Product Name
Posted: Sat Feb 11, 2012 11:23 am
by uniqu3
JimboDavies move it to top of your template outside html tags like:
Code: Select all
<!doctype>{process_pagetemplate}
{strip}
{content assign='get_content'}
{capture assign ='get_title'}
{if isset($producttitle)}
{$producttitle}
{else}
{title}
{/if}
{/capture}
{/strip}
<__html>
<head>
<title>{$get_title} - {sitename}</title>
<!-- now your head stuff -->
</head>
</__body>
<!-- your body stuff -->
<h1>{$get_title}</h1>
{$get_content}
<__body>
</__html>
Re: HTML Title on Products Page set to Product Name
Posted: Sat Feb 11, 2012 11:28 am
by JimboDavies
Marek, Goran,
Thanks for all your help - that's worked like a charm.
This will make a big difference to my SEO I hope!
Cheers,
Jimbo