create content blocks as many as you want! in your temlate!:
{content block='Name' assign='Name' oneline="true"}
{content block='Title2' assign='Title2' oneline="true"}
{content block='Description2' assign='Description2' oneline="true"}
.
.
.
then use it in where U want:
{if code}
{$Description2} - {$Title2}
{else}
{Description} - {Title} - {$Name}
{/if}
SEO friendly pages for CMSMS
-
- Forum Members
- Posts: 36
- Joined: Sat Jun 27, 2009 10:52 am
Re: SEO friendly pages for CMSMS
Last edited by spiriralph on Fri Jul 31, 2009 6:47 am, edited 1 time in total.
Re: SEO friendly pages for CMSMS
@motoph
These things already exist, look at the options tab...
These things already exist, look at the options tab...
Re: SEO friendly pages for CMSMS
Before it became std (or I just didn't figure it), I did my own thing, ie:
1. create 2 x UDT's ie "description" and "keywords"
Description UDT:
and "keywords" UDT.
"keywords" UDT is slightly different to "description" UDT as many clients want to go overboard with the number of keywords so var "titlekeywords" limits it to the first 5 words.
On each page I use in the Smarty data or logic that is specific to this page:
{description content="blah blah blah"}
{keywords content="site,keywords,whatever,and so on, etc, however many..."}
In the Page Specific Metadata text area add:
and add the {$titlekeywords} and {$metadescription} tags wherever I want in the template not just as meta tags, eg as the alt text for the header banner image, in the page title and with 'class='accessibility' in the footer.
I also add a Global Content Block and 'if' statement in the template that says if there is no page specific metadescription or keywords, use the default GCB text.
No doubt it's the long way round but seems to work for me and Google.
HTH
psy
1. create 2 x UDT's ie "description" and "keywords"
Description UDT:
Code: Select all
global $gCms;
$smarty = &$gCms->GetSmarty();
if ($params['content'] && $params['content'] != '')
{
$smarty->assign ( "metadescription", $params['content'] );
}
else
{
return;
}
Code: Select all
global $gCms;
$smarty = &$gCms->GetSmarty();
if ($params['content'] && $params['content'] != '')
{
$smarty->assign ( "keywords", $params['content'] );
$x= str_replace(',', ' ',$params['content']);
if ( str_word_count($x) > 5) {
$y = explode (',',$params['content']);
$titlekeywords = ucwords ($y[0] . " " . $y[1] . " " . $y[2] . " " . $y[3] . " " . $y[4]);
} else {
$titlekeywords = $x;
}
$smarty->assign ( "titlekeywords",ucwords($titlekeywords) );
} else {
return;
}
On each page I use in the Smarty data or logic that is specific to this page:
{description content="blah blah blah"}
{keywords content="site,keywords,whatever,and so on, etc, however many..."}
In the Page Specific Metadata text area add:
and add the {$titlekeywords} and {$metadescription} tags wherever I want in the template not just as meta tags, eg as the alt text for the header banner image, in the page title and with 'class='accessibility' in the footer.
I also add a Global Content Block and 'if' statement in the template that says if there is no page specific metadescription or keywords, use the default GCB text.
No doubt it's the long way round but seems to work for me and Google.
HTH
psy
-
- Forum Members
- Posts: 83
- Joined: Mon Nov 03, 2008 1:28 pm
Re: SEO friendly pages for CMSMS
How am I supposed to create a meta title that is not the sitename+H1 title? I see no answer to this question.
Last edited by mvandiermen on Thu Sep 24, 2009 9:36 pm, edited 1 time in total.
Re: SEO friendly pages for CMSMS
Improved the code a little further, as I needed meta tags, title etc. from specific pages. So easier if it all would belong to the same UDT. And as plus, I adjusted that for MLE.
Code: Select all
global $gCms;
$db =& $gCms->GetDb();
$content_ids = array($gCms->variables['pageinfo']->content_id);
$content_aliases = array();
$props = array();
$prop_separator = '<br />';
$page_separator = '<hr />';
$result = array();
$order_by = "hierarchy";
$q = $qc = array();
$p = $pc = array();
$where_props = array();
$where_id = array();
$where_alias = array();
if( isset($params['content_id']) ) {
$content_ids = explode(",",trim($params['content_id']));
}
if( isset($params['content_alias']) ) {
$content_aliases = explode(",",trim($params['content_alias']));
}
if( isset($params['props']) ) {
$props = explode(',',trim($params['props']));
}
if( isset($params['prop_separator']) ) {
$prop_separator = $params['prop_separator'];
}
if( isset($params['page_separator']) ) {
$page_separator = $params['page_separator'];
}
$query = "SELECT P.prop_name, P.content, P.content_id, C.content_alias
FROM ".cms_db_prefix()."content C, ".cms_db_prefix()."content_props P
WHERE P.content_id = C.content_id";
if( !empty($content_aliases) ) {
foreach($content_aliases as $c_alias) {
$where_alias[] = "C.content_alias = ?";
$p[] = trim($c_alias);
$pc[] = trim($c_alias);
}
}
else if( !empty($content_ids) ) {
foreach($content_ids as $c_id) {
$where_id[] = "P.content_id = ?";
$p[] = trim($c_id);
$pc[] = trim($c_id);
}
}
if(!empty($props)) {
foreach($props as $f)
{
$where_props[] = "P.prop_name = ?";
$p[] = trim($f);
}
}
if(count($where_props) || count($where_alias) || count($where_id)) {
if(count($where_alias)) {
$q[] = " (".implode(" OR ",$where_alias).") ";
$qc[] = " (".implode(" OR ",$where_alias).") ";
}
else if(count($where_id)) {
$q[] = " (".implode(" OR ",$where_id).") ";
$qc[] = " (".implode(" OR ",$where_id).") ";
}
if(count($where_props)) {
$q[] = " (".implode(" OR ",$where_props).") ";
}
if(count($q))
$query .= " AND ".implode(" AND ",$q);
}
$query .= " ORDER BY ".$order_by;
$dbresult = $db->Execute($query,$p);
while($dbresult && $row = $dbresult->FetchRow()) {
$result[$row['content_alias']][$row['prop_name']]['prop_name'] = $row['prop_name'];
$result[$row['content_alias']][$row['prop_name']]['data'] = $row['content'];
$result[$row['content_alias']]['content_id'] = $row['content_id'];
$result[$row['content_alias']]['content_alias'] = str_replace("-","_",$row['content_alias']);
}
//Start MLE
global $hls, $hl;
$lang_query = array();
$lang_add = isset($hls) ? "_" . $hls[$hl]['parent'] : "";
$lang_attr = array("content_name", "menu_text", "metadata", "titleattribute");
foreach($lang_attr as $key) {
$lang_query[] = "C.".$key . $lang_add . " " . $key;
}
// query stuff
$query = "SELECT C.content_alias, " . implode(",",$lang_query) . "
FROM ".cms_db_prefix()."content C WHERE 1 ";
if(count($qc))
$query .= " AND ".implode(" AND ",$qc);
$dbresult = $db->Execute($query,$pc);
while($dbresult && $row = $dbresult->FetchRow()) {
foreach($lang_attr as $key) {
$result[$row['content_alias']][$key]['prop_name'] = $key;
$result[$row['content_alias']][$key]['data'] = $row[$key];
}
}
//End MLE
// assign vars to smarty
// you can use both params at once (but with different values)
if( isset($params['assign']) || isset($params['assign_as_array']) ) {
// first just the whole values as one string
if( isset($params['assign']) ) {
$return = array();
foreach($result as $res) {
$ret = array();
foreach($res as $prop) {
$ret[] = $prop['data'];
}
$return[] = implode($prop_separator,$ret);
}
$r = implode($page_separator,$return);
$smarty->assign(trim($params['assign']), $r);
}
// or more complex the whole result as array
// so you can play with it in your template via smarty
if( isset($params['assign_as_array']) ) {
$smarty->assign(trim($params['assign_as_array']), $result);
}
}
// or just print out the result
else {
$return = array();
foreach($result as $res) {
$ret = array();
foreach($res as $prop) {
$ret[] = $prop['data'];
}
$return[] = implode($prop_separator,$ret);
}
$r = implode($page_separator,$return);
echo $r;
}
-
- Forum Members
- Posts: 83
- Joined: Mon Nov 03, 2008 1:28 pm
Re: SEO friendly pages for CMSMS
Another solution is to hide the title div on the page you want to create a custom meta tag for; so that you can enter in a title that does not come out on the homepage for instance
Template:
{title}
{content}
Page Specific Metadata:
{literal}
{/literal}
Template:
{title}
{content}
Page Specific Metadata:
{literal}
{/literal}
Last edited by mvandiermen on Sun Sep 27, 2009 8:42 pm, edited 1 time in total.
Re: SEO friendly pages for CMSMS
You don't have to use the {title} tag in the page, you can just use it in the in , then put all kinds of stuff in it...
This site uses title tag in head, not in content/page area, to get long description in head...
http://www.metachrome.co.uk/
This site uses title tag in head, not in content/page area, to get long description in head...
http://www.metachrome.co.uk/