Child pages
  • [cms] Allow specifying "robots" meta for pages [5.3.0-B1]
Skip to end of metadata
Go to start of metadata

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

/themes/advanced/platform/elements/html_head.elm.tpl
<inp2:m_if check="st_PageInfo" type="meta_nofollownoindex">
	<meta name="robots" content="<inp2:st_PageInfo type='meta_nofollownoindex'/>"/>
</inp2:m_if>
/core/admin_templates/categories/categories_edit.tpl
<div id="scroll_container">
   <table class="edit-form">
	
	.....

	<inp2:m_RenderElement name="inp_edit_checkboxes" prefix="c" field="MetaNofollowNoindex"/>
 
	.....
 
	<!-- custom fields: begin -->
	<inp2:m_include t="incs/custom_blocks"/>
	<inp2:cf.general_PrintList render_as="cv_row_block" SourcePrefix="c" value_field="Value" per_page="-1" grid="Default" />
	<!-- custom fields: end -->

	<inp2:m_RenderElement name="inp_edit_filler"/>
</table>
sql
ALTER TABLE {TABLE_PREFIX}Categoies ADD `MetaNofollowNoindex` VARCHAR(30) NULL DEFAULT NULL;

/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,
	),
	.....
),
/core/units/categories/categories_tag_processor.php
function PageInfo($params)
{
	$page =& $this->_getPage($params);

	switch ($params['type']) {
		.....

		case 'meta_nofollownoindex':
			$db_field = 'MetaNofollowNoindex';
			break;

		.....

		default:
			return '';
 	}

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

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

	return $val;
}

Related Tasks

INP-1592 - Getting issue details... STATUS

1 Comment

  1. I've updated tags used on Front-End templates:

    • use "st" instead of "st.current" or "c.current"
    • use "st_PageInfo" tag consistently in "m_if" condition and it's contents

    Also suggesting to rename field from "MetaNofollowNoindex" into "MetaRobotsExclusions", because it universally represents what field does and not just "nofollow" and "noindex" options only.