[SOLVED] HTML Title on Products Page set to Product Name

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

[SOLVED] HTML Title on Products Page set to Product Name

Post 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
Last edited by JimboDavies on Sat Feb 11, 2012 11:28 am, edited 1 time in total.
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

Re: HTML Title on Products Page set to Product Name

Post 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.
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am

Re: HTML Title on Products Page set to Product Name

Post by applejack »

In your config file what is the process whole template option set to? It should be false.
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

Re: HTML Title on Products Page set to Product Name

Post by JimboDavies »

yes, its set to FALSE.
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

Re: HTML Title on Products Page set to Product Name

Post 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.
maranc
Forum Members
Forum Members
Posts: 249
Joined: Tue May 04, 2010 5:04 pm

Re: HTML Title on Products Page set to Product Name

Post by maranc »

Its a problem with rendering content, after </__body> section set this code:

Code: Select all

{content assign='mycontent'}
Change {content} for {mycontent}.

Now it should be work.

Marek A.
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

Re: HTML Title on Products Page set to Product Name

Post by JimboDavies »

Hi Marek,

I have

Code: Select all

{content assign="get_content"}
in my page head, and

Code: Select all

{$get_content}
in the page body.

If I read you correctly, I should move the content assign into the body to fix this?

Cheers.
uniqu3

Re: HTML Title on Products Page set to Product Name

Post 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>
JimboDavies
Forum Members
Forum Members
Posts: 130
Joined: Fri Feb 25, 2011 3:58 pm

Re: HTML Title on Products Page set to Product Name

Post 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
Post Reply

Return to “Modules/Add-Ons”