Page 1 of 1
Custom meta tag "description" in News
Posted: Tue Dec 22, 2015 11:39 am
by zener
Hi, I'm trying to have custom "meta description" tag in CMS Made Simple 2. I have in section this code and it works.
Code: Select all
<meta name="Description" content="{description}">
The problem is in News module. There isn't field to fill description tag. So I can't write description.
Any ideas? Thank you!
Re: Custom meta tag "description" in News
Posted: Tue Dec 22, 2015 12:12 pm
by Rolf
In the top of the News Detail Template
Code: Select all
{$canonical = $entry->canonical scope=global}
{if empty($entry->content)}
{$description = $entry->summary|strip_tags|strip|truncate:150 scope=global}
{else}
{$description = $entry->content|strip_tags|strip|truncate:150 scope=global}
{/if}
{$page_title = $entry->title|cms_escape:htmlall scope=global}
Example Page Template
Code: Select all
{strip}
{process_pagedata}
{$canonical = "{$content_obj->GetURL()|lower|default:''}" scope=global}
{$description = "{description}" scope=global}
{$page_title = "{title}" scope=global}
{$content = "{content}" scope=global}
{if empty($description)}{$description = $content|strip_tags|strip|truncate:150|default:'' scope=global}{/if}
{/strip}<!DOCTYPE HTML>
< html lang="en">
<head>
<meta name="description" content="{$description}">
<link rel="canonical" href="{$canonical}">
</head>
< body>
<h2>{$page_title}</h2>
{$content}
< /body>
< /html>
Re: Custom meta tag "description" in News
Posted: Mon Dec 28, 2015 1:01 am
by zener
THX for you reply but it doesn't work for me
News Detail template
Code: Select all
{* News module entry object reference:
------------------------------
...
====
Below, you will find the normal detail template information. Modify this template as desired.
*}
{$canonical = $entry->canonical scope=global}
{if empty($entry->content)}
{$description = $entry->summary|strip_tags|strip|truncate:150 scope=global}
{else}
{$description = $entry->content|strip_tags|strip|truncate:150 scope=global}
{/if}
{$page_title = $entry->title|cms_escape:htmlall scope=global}
<h2>{$entry->title|cms_escape:htmlall}</h2>
Layout template
Code: Select all
{strip}
{process_pagedata}
{$canonical = "{$content_obj->GetURL()|lower|default:''}" scope=global}
{$description = "{description}" scope=global}
{$page_title = "{title}" scope=global}
{if empty($description)}{$description = $content|strip_tags|strip|truncate:150|default:'' scope=global}{/if}
{/strip}
{* == PROCESS DATA & HEAD == *}
{global_content name='Head'}
{* === BLACK BG === *}
<div id="page-bg">
<div id="page">
HEAD section
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<__html lang="cs">
<head>
{metadata}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Language" content="en">
<meta name="Language" content="en">
<meta name="Copyright" content="© Site">
<meta name="Robots" content="index,follow">
<meta name="Author" content="ME">
<meta name="Keywords" content="">
<meta name="Description" content="{$description}">
<meta name="viewport" content="width=device-width, initial-scale=1">
And the rendered page (any News)
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<__html lang="cs">
<head>
<base href="http://example.cz/" />
<meta name="Generator" content="CMS Made Simple - Copyright (C) 2004-2015. All rights reserved." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="Content-Language" content="en">
<meta name="Language" content="en">
<meta name="Copyright" content="© Site">
<meta name="Robots" content="index,follow">
<meta name="Author" content="Me">
<meta name="Keywords" content="">
<meta name="Description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
Any ideas? Thank you.
Re: Custom meta tag "description" in News
Posted: Tue Dec 29, 2015 8:38 pm
by Rolf
You haven't take over the {$content = "{content}" scope=global} and {$content} part from my example template above...