Page 1 of 1
[solved] SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Thu Oct 09, 2014 1:58 pm
by paulbaker
I have SEOTools2 and CGBlog running on 1.11.11.
I want to control the HTML
TITLE of the blog article pages.
I have a Blog page template which is used for both the summary listing and also the detail listing.
When a detail blog post is viewed I need the TITLE to be
TITLE OF BLOG POST | company name etc...
When a summary of blog articles is shown I need the TITLE to be simply
Blog | company name etc...
In SEOTools2 I have the TITLE set as
The blog page title is Blog. And in the Page template I have:
Code: Select all
{if $entry->title != ""}
TEST:{$entry->title}
{SEOTools2|replace:'Blog |':'{$entry->title} |' showbase="false"}
{else}
{SEOTools2 showbase="false"}
{/if}
However this shows on the site as:
Code: Select all
TEST:BlogTitle
<title>{$entry->title} | company name etc...</title>
So $entry->title is the right variable but I haven't called it correctly in the SEOTools2 call because it's not parsing. I even tried {eval var=$entry->title} but got the same result.
Plus another problem is that on the
summary page it does exactly the same, whereas I want the summary page TITLE to be just Blog | as above.
Can someone point me in the right direction please?

Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Thu Oct 09, 2014 8:14 pm
by velden
Wild guess: try double quotes:
Code: Select all
{SEOTools2|replace:'Blog |':[color=#FF0000]"[/color]{$entry->title} |[color=#FF0000]"[/color] showbase="false"}
or even better perhaps:
Code: Select all
{SEOTools2|replace:'Blog |':$entry->title} |" showbase="false"}
That said, I don't think it's a very elegant solution. But sometimes the (not so) quick and dirty way fits.
To distinct between summary and detail look for template vars ($actionparam iirc).
Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Thu Oct 09, 2014 8:15 pm
by psy
The fields in SEO2 are Smarty enabled so you can apply your logic there instead of in your template.
1. Assign a var, eg $blogtitle, the value of $entry->title in your detail template
2. In SEOTools2, use Smarty logic to determine what to show for the title, eg
Code: Select all
{if isset($blogtitle)}{$blogtitle}{else}{title}{/if} | company, etc...
Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Thu Oct 09, 2014 8:37 pm
by psy
Another solution to the problem...
1. Above {process_pagedata} in your page template, put {title assign='mytitle'}
2. In the Title field of SEO2 put {$mytitle} | {sitename} etc
3. In your blog detail template put {$mytitle=$entry->title}
Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Fri Oct 10, 2014 10:00 am
by paulbaker
psy wrote:Another solution to the problem...
Yay! That did it. Had to put the assign
after the {process_pagedata} call though.
Here's what solved it:
1. Just after {process_pagedata} in your page template, put {title assign='mytitle'}
2. In the Title field of SEO2 put {$mytitle} | {$sitename} etc
3. In your blog detail template put {$mytitle=$entry->title}
This leaves the HTML TITLE as "Blog..." for the summary page but puts the blog post title in the HTML TITLE for the detail pages. Simple and straightforward...even I can understand it.
Thank you psy and velden!
Now, I tried to do something similar with the description by putting this in the blog detail template:
Code: Select all
{assign var='metadescription' value=$entry->summary|strip_tags|truncate:250}
but no luck. I am trying to override the SEOTools2 metadescription so it shows a specific meta description tag for each blog post. Is that possible?
Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Fri Oct 10, 2014 10:18 am
by psy
What I do is...
In SEO2 field 'Module custom field keywords Smarty var:' I enter the value : detail_keywords
In CGBlog I create 2 text field defs, ie 'Keywords' and 'Metadescription' and in the CGBlog detail template put:
Code: Select all
{if !empty($entry->fields.Keywords->value)}
{assign var='detail_keywords' value=$entry->fields.Keywords->value}
{/if}
{if !empty($entry->fields.Metadescription->value)}
{assign var='metadescription' value=$entry->fields.Metadescription->value}
{/if}
where 'metadescription' is the name of var for same in SEO2 and in the page template:
Code: Select all
{if empty($metadescription)}{content block='description' label='META Description' oneline='true' assign='metadescription'}{/if}
Then CGBlog summary page shows the SEO2 defined keywords and page defined metadescription.
In the CGBlog detail page, the above 2 are overwritten by the article keywords and metadescription.
End result of all this is that you get a custom title, keyword set and meta description for every blog article.
HTH
psy
Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Fri Oct 10, 2014 10:29 am
by psy
1. Just after {process_pagedata} in your page template, put {title assign='mytitle'}
Check that your other pages (not CGBlog detail) are getting the correct title.
It's quite possible my logic is up the creek.

Re: SEOTools2 + CGBlog: controlling HTML TITLE
Posted: Fri Oct 10, 2014 11:07 am
by paulbaker
psy wrote:HTH
YES. Thank you. It most certainly did help, and I now have the site doing what I need it to do and working well when you share the blog posts on Facebook. Mostly thanks to the help you provided psy.
Yes all other normal pages have good titles too.
Thanks again!
