SEO Friendly titles for modules in CMSMS

Quick note about this post – if you don’t use CMSMS, skip it =)

CMSMS is pretty good for SEO, but one of the things that does bug me is that by default, it doesn’t set titles for pages generated by modules.

For example, on a news page, you want the title of the page to be the name of the news post instead of ‘News’. Here’s how to do just that.

I’ve used the news module as an example, but it works with any module.

1. Disable ‘process_whole_template’

In config.php, change this line:

$config['process_whole_template'] = true;


to

$config['process_whole_template'] = false;


Also make sure that you don’t have the {process_pagedata} tag in your template.

The process_whole_template setting makes the template be processed before processing any of the calls it makes. We want to turn it off because otherwise we have no way of getting the title from the News module .

2. Assign the title variable

  • Go to Content → News
  • Click on “Detail Template” tab
  • Edit your template (in most cases the default is named ‘Sample’, do it for every news detail template you have)

In the top of your template put this code:

{assign var='pagetitle' value=$entry->title}


This assigns the title of the news post to a variable we can use later

3. Update your site template to use the new variable

Open up your site template, and in the first line put:

{content assign="capturedcontent"}


Then replace your {content} tag with {$capturedcontent}.

Now we just need to actually use the title we’ve got set in the pagetitle variable.

The title of your page will look something like this:

<title>{title} | {sitename}</title>


Change it to :

<title>{if isset($pagetitle)}{$pagetitle} | {sitename}{else}{title} | {sitename}{/if}</title>


The line checks to see if pagetitle is set, and if it is, we set the title to be {$pagetitle} instead of {title}

All done!

If you enjoyed this post, make sure you subscribe to my RSS feed!


Related posts:

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

2 Responses to “SEO Friendly titles for modules in CMSMS”

  1. Thanks for that! It’s sure to come in handy.

    I’ve just started using CMSMS and after a bit of a rocky learning curve with some of the modules (mainly just learning which are the best modules for the job) I think I’ve finally got it nutted out. Things just work the way I’d expect them to work, which is more than I can say for a lot of popular CMSs out there. I look forward to using it more often and would love to hear any other less-obvious tips and tricks that you’ve learned along the way.

  2. Hi Mikey, I’ve got quite a few more lined up. I had this all written out on BackPackIt pages so I could easily refer to them, but I’m cancelling my account so I’m transferring them all over here =)

    Good to hear you’ve moved over to CMSMS =) Happy to help if you have any questions about which modules are good, etc.