Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

On website there are pages of 2 conceptual types:

  • pages that makes sense for robots (e.g. Google) to index (show in search results)
  • pages, that doesn't make to index (e.g. "No Permissions", "Form Submitted Template")

For later page category it makes sense to add following into <head>:

<meta name="robots" content="nofollow, noindex, noarchive"/>

Solution

html_head.elm.tpl
<inp2:m_if check="c.current_Field" name="MetaKeywords"><meta name="Keywords" content="<inp2:c.current_PageInfo name='MetaKeywords'/>"/></inp2:m_if>
/core/units/categories/categories_config.php
'Fields' => Array (
/------------------- .......... -------------------/
'MetaNofollowNoindex' => Array (
	'type' => 'string',
	'formatter' => 'kOptionsFormatter', 'options' => Array ('nofollow' => 'NoFollow', 'noindex' => 'NoIndex', 'noarchive' => 'NoArchive', 'noimageindex' => 'NoImageIndex', 'noodp' => 'NoOdp',  'nosnippet' => 'NoSnippet'),
 	'default' => NULL
),
/------------------- .......... -------------------/
),

 


file: categories_tag_processor.php

function PageInfo($params)
{
 $page =& $this->_getPage($params);

 switch ($params['type']) {
 case 'title':
 // TODO: rename column to SectionTitle
 $db_field = 'Name'; // "Section Title" - title to show on page (e.g. in <h1> tag)
 break;

 case 'htmlhead_title':
 // TODO: rename column to HtmlTitle
 $db_field = 'Title'; // "Title (on Page)" - in <title> html tag
 break;

 case 'meta_title':
 $db_field = 'MetaTitle';
 break;

 case 'menu_title':
 $db_field = 'MenuTitle'; // "Title (Menu Item)" - in menu and navigation bar
 break;

 case 'meta_keywords':
 $db_field = 'MetaKeywords';
 $cat_field = 'Keywords';
 break;

 //---------------!!!!!!!!!!!!!!!!!!!!!!
case 'meta_nofollownoindex':
 $db_field = 'MetaNofollowNoindex';
 break;
 
 //---------------!!!!!!!!!!!!!!!!!!!!!!


 case 'meta_description':
 $db_field = 'MetaDescription';
 $cat_field = 'Description';
 break;

 case 'tracking':
 case 'index_tools':
 if (!EDITING_MODE) {
 $tracking = $page->GetDBField('IndexTools');
 return $tracking ? $tracking : $this->Application->ConfigValue('cms_DefaultTrackingCode');
}
 // no break here on purpose

 default:
 return '';
}

 $default = isset($params['default']) ? $params['default'] : '';
 $val = $page->GetField($db_field);

 //---------------!!!!!!!!!!!!!!!!!!!!!!
 if ($db_field == 'MetaNofollowNoindex') {
 return str_replace('|',', ',trim($val,'|'));
}
 //---------------!!!!!!!!!!!!!!!!!!!!!!

 if (!$default) {
 if ($this->Application->isModuleEnabled('In-Portal')) {
 if (!$val && ($params['type'] == 'meta_keywords' || $params['type'] == 'meta_description')) {
 // take category meta if it's not set for the page
 return $this->Application->ProcessParsedTag('c', 'Meta', Array('name' => $cat_field));
}
}
}

 if (isset($params['force_default']) && $params['force_default']) {
 return $default;
}

 if (preg_match('/^_Auto:/', $val)) {
 $val = $default;

 /*if ($db_field == 'Title') {
$page->SetDBField($db_field, $default);
$page->Update();
}*/
 }
 elseif ($page->GetID() == false) {
 return $default;
}

 return $val;
}

file categories_edit.tpl
<inp2:m_RenderElement name="inp_edit_checkboxes" prefix="c" field="MetaNofollowNoindex" title="la_fld_MetaNofollowNoindex" />



 sql for update table Categories

ALTER TABLE TABLE_PREFIX.Categories ADD `MetaNofollowNoindex` VARCHAR(30) NULL DEFAULT NULL AFTER `RequireLogin`;




 
  • No labels