section this code: section this code: section this code:

CMS Made Simple: Custom meta tag "description" in News

617 Views Asked by At

I'm trying to have custom "meta description" tag in CMS Made Simple 2. I have in <HEAD> section this code: <meta name="Description" content="{description}"> and it works.

The problem is in News module. There isn't field to fill description tag. So I can't write description.

Any ideas? Thank you!

2

There are 2 best solutions below

0
Ervin On

Look up for MetaMax module,

and try adding meta tags with og: (OpenGraph protocol). Personally never used that CMS before, i just googled it right now, so my answer is just a guess.

<meta property="og:description" content=" "/>
0
KiwiChris On

If you want to have a custom description for each news item, you need to create a custom field in the News Module .e.g. pageDescription. Then in the News Detail template put the line

{if !empty($entry->fields['pageDescription']->value)}{$pageDescription=$entry->fields['pageDescription']->value scope=global}{/if}

That creates the global smarty variable $pageDescription.

Then in Global Metadata (or wherever you are placing the meta tags, add:

{if !empty($pageDescription)}<meta name="description" content="{$pageDescription}">{else}<meta name="description" content="{description}">{/if}

OR, instead of the custom field above, you could just use a truncated version of the News summary section (in News Detail template)...

{if !empty($entry->summary)}{$pageDescription=$entry->summary|strip_tags:false|cms_escape:htmlall|truncate:160}{/if}