Hi, I need a field to add value robots meta tag, not just check to add noindex and nofollow as well as the option to add the index and follow.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

DamienMcKenna’s picture

FileSize
33.46 KB

Do you mean e.g. checkboxes for all of the ROBOTS options, like Nodewords has?
Nodewords' robots options.

Prague man’s picture

Yes, I solved it adding these lines to code:

// More advanced meta tags.
  $info['tags']['robots'] = array(
    'label' => t('Robots'),
    'description' => t("Provides search engines with specific directions for what to do when this page is indexed."),
    'class' => 'DrupalListMetaTag',
    'form' => array(
      '#options' => array(
        'noindex' => t('Prevent search engines from indexing this page.'),
        'nofollow' => t('Prevent search engines from following links on this page.'),
		<strong>'follow' => t('Enable follow.'),
		'index' => t('Enable index.'),</strong>
        'noarchive' => t('Prevent a cached copy of this page from being available in the search results.'),
        'nosnippet' => t('Prevents a description from appearing below the page in the search results, as well as prevents caching of the page.'),
        'noodp' => t('Blocks the <a href="@odp-url">Open Directory Project</a> description of the page from being used in the description that appears below the page in the search results.', array('@odp-url' => 'http://www.dmoz.org/')),
      ),
    ),
    'group' => 'advanced',
  );

and thats working.

Prague man’s picture

without <strong> attributes.

FiNeX’s picture

I agree with Prague man, the solution works fine. But it should be added a condition in order to exclude "noindex" and/or "nofollow" if "index" and/or "follow" have been selected and vice versa. Maybe when "index" is selected then "noindex" should be deselected and deactivated.

What do you think about?

DamienMcKenna’s picture

Title: Need to field for add meta tag value for robots » Add missing ROBOTS options
Status: Active » Needs review
FileSize
1.27 KB

This patch adds FOLLOW, INDEX and NOYDIR.

DamienMcKenna’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Andre-B’s picture

Issue summary: View changes

in case anybody is running into the issue with having the bad ordering as "follow, index" as a problem (it should be index, follow):

/**
 * Fix bad ordering for robots metatag
 *
 * @param $output
 * @param $instance
 * @param $options
 */
function mymodule_metatag_metatags_view_alter(&$output, $instance, $options) {
  if (isset($output['robots']['#attached']['drupal_add_html_head'][0][0]['#value'])) {
    if ($output['robots']['#attached']['drupal_add_html_head'][0][0]['#value'] == 'follow, index') {
      $output['robots']['#attached']['drupal_add_html_head'][0][0]['#value'] = 'index, follow';
    }
  }
}