It would be great to have more metatags available, e.g."robots".
Example:
<meta name="robots" content="index, follow" />
and more generalized something like:
<meta name="$name" content="$value" />
as a multi valued field.

cheers, Ronald

CommentFileSizeAuthor
#8 beanstag.module.txt11.2 KBykyuen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ykyuen’s picture

Assigned: Unassigned » ykyuen

For simplicity, i just set page title, meta keywords and description in the beanstag form. The generic approach would be a nice feature but that requires a big change on the module db schema and code.

Except robots, whatelse of meta name attributes would u like to add? i could make a quick fix for you first.

rokr’s picture

At this time robots would be the most important. We really like the approach of beanstag and evaluating it for a site where SEO maintainers don't want to take care about site structure (nodes, panels, views, etc).

thanks, Ronald

vintorg’s picture

yk, this is a great module. Can you add support for canonical tags?

ykyuen’s picture

Hi rokr,

i will try to complete the robot feature just like the keywords and description entries. currently i will not implement the generic approach.

It should be done in the coming 2 days.

Hi vintorg,

Are you looking for sth like
<link rel="canonical" href="http://www.example.com/product.php?item=swedish-fish"/>

If this is what you need, i will try to add it for you too. should be ok in coming 2 days.

Regards,
Kit

vintorg’s picture

Hey yk, yes! That would be perfect!

ykyuen’s picture

Hi rokr and vintorg,

i have committed the changes. please checkout the latest code and run update.php as it involves schema changes.
After the update, you can enable the meta robots and canonical @admin/config/search/beanstag.

Once you have enabled the 2 new options, you could find the 2 new options when adding/editing beanstag just like the meta description and canonical.

Let me know if there is any problem.

Regards,
Kit

markomat’s picture

Great work, Kit! Thanks for adding the new fields. I'm really looking forward to actually use the module.

I just tried out the latest version and it works pretty well. But I noticed that the new Canonical tag is just added to the header, it's not replacing the default element (even with vverriding). So you get two canonicals which might confusing.

I added a few lines to the function beanstag_html_head_alter() to unset the default canonical if the override option is activated.

// Remove default canonical link, if beanstag is configured to override existing meta tags
if (variable_get('beanstag_override', 0) == 1){
  foreach ($head_elements as $key => $element) {
    if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
     unset($head_elements[$key]);
    }
  }
}

/* followed by the line */
// Add meta tag only when there is no existing meta keywords

Sorry, i could not write a proper patch.
What do you think?

Cheers
Mark

ykyuen’s picture

FileSize
11.2 KB

Hi Mark,

Thanks for your snippet, but i think it would be better to check the existing canonical link before adding the beanstag meta_canonical, so i add the checking at

 // Insert meta canonical if it exists and beanstag_enable_meta_canonical is enabled
  if (variable_get('beanstag_enable_meta_canonical', 0) == 1) {
    if ($beanstag->meta_canonical) {
      $set_canonical = TRUE;
      
      // Check if there is any existing meta canonical
      foreach ($head_elements as $key => $element) {
        if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') {
          if (variable_get('beanstag_override', 0) == 1){
            // Remove default canonical link, if beanstag is configured to override existing meta canonical
            unset($head_elements[$key]);
          } else {
            // Keep existing meta canonical
            $set_canonical = FALSE;
          }
        }
      }
      
      if ($set_canonical) {
        $head_elements['beanstag_canonical'] = array(
          '#type' => 'html_tag',
          '#tag' => 'link',
          '#attributes' => array('rel' => 'canonical', 'href' => check_plain(token_replace($beanstag->meta_canonical, $data))),
        );
      }
    }
  }

This can ensure no double canonical links are rendered.

I have tested, seems it works fine. Would you help to try the attached .module file?

If it works for you, i will commit the changes to the drupal repo.

Thanks for your code. =)

markomat’s picture

Wow, you are fast!
I tested your update and it seems to work as it should. - very cool.
Thank you.

ykyuen’s picture

Code committed, thanks again for your code. =D

ykyuen’s picture

Status: Active » Closed (fixed)