Page 1 of 1

CGBlog and geting title

Posted: Wed Nov 18, 2020 9:21 pm
by andrewvideouk
Hi I am trying to get the title from a blog post into the main template. I am using the defut temples are in the CGBlog.

I found this page which might be out of date and for CMSMS version 1.12 and I have the lastest version.
https://www.sigmaweb.co.uk/2015/09/CGBl ... s-to-Posts.

Also the site http://www.i-do-this.com/ is download. :(

Can someone point me to a updated guide please or how to.

Thank you

Re: CGBlog and geting title

Posted: Wed Nov 18, 2020 10:15 pm
by DIGI3
In the top of the blog detail template, you could set something like:

Code: Select all

{$blogtitle=$entry->title scope=global}
Then in your page template you should have access to $blogtitle, which you can use for conditionally changing $title or whatever else you like. I often do something like:

Code: Select all

{if $blogtitle}
  {$title=$blogtitle}
{else}
  {$title={title}}
{/if}
<title>{$title} - {sitename}</title>

Re: CGBlog and geting title

Posted: Thu Nov 19, 2020 7:57 am
by velden
Personally I like this approach: https://cmscanbesimple.org/blog/base-cm ... d-metatags

Especially because it doesn't need the if-then-else construct.

Re: CGBlog and geting title

Posted: Thu Nov 19, 2020 11:12 am
by Rolf
velden wrote: Thu Nov 19, 2020 7:57 am Personally I like this approach: https://cmscanbesimple.org/blog/base-cm ... d-metatags

Especially because it doesn't need the if-then-else construct.
The method I describe here collects all possible (default) values and passes them to the template with general names, so you can use them for multiple purposes. Simple, but very powerful!

Re: CGBlog and geting title

Posted: Thu Nov 19, 2020 4:46 pm
by andrewvideouk
I well have a read and add it to my template. That so much better to do that as my template is getting messy with if-then-else.

Thank you guys.