Ok, I know we have meta tags, why should we complain?

Because we have clients who like to build duplicate content on multiple pages -- we need to handle them even if there might be better ways to arrange things.

The canonical meta tag [http://en.wikipedia.org/wiki/Canonical_meta_tag] according to my SEO guys, is the ugly step-sister of meta tags. Still we need it.

So I needed a means to output
instead of and use the 'rel' and 'href' attributes instead of the 'name' and 'content' this could easily be extended by others who don't mind getting their sleeves dirty, but I'm just after the quick and dirty solution for now.

So, this semi-patch I'm using works exactly like the regular metatags quick, except if you add a meta tag name of 'canonical' -- in which case this code generates a properly formated
tag instead of .

I don't know if a later version fixes this or not, but I can't risk breaking a working system for regular meta tags now, when we've already delivered. So this might be only useful to 1 developer in 50,000 -- but just in case, I have a slight hack to make metatags quick handle canonical meta tag.

: -- in 7.x-1.0-beta4
file: metatags_quick.module
lines: 81-87
code was:

    $element = array(
      '#tag' => 'meta',
      '#attributes' => array(
        'name' => $meta_name,
        'content' => $item[0]['metatags_quick'],
      ),
    );

I made this hack to handle canonical:

    if ('canonical' == $meta_name)
    { 
      $attr = array ( 'rel' =>$meta_name
                  ,   'href'=>$item[0]['metatags_quick']
                  , );
      $element  = array ( '#tag'        =>'link'
                      ,   '#attributes' =>$attr
                      , );
    }                 
    else              
    {
      $attr = array ( 'name'    =>$meta_name
                  ,   'content' =>$item[0]['metatags_quick']
                  , );
      $element  = array ( '#tag'        =>'meta'
                      ,   '#attributes' =>$attr
                      , );
    } 

This is obviously not in the style for a patch, because I don't have time, and I can't stand the formating aspects of it. If someone else (maintainer?) finds this is useful, then Feel free to muck up my arrays the way you guys like.

Comments

jefkin’s picture

Sorry, forgot to use < ... in my issue:

So I needed a means to output <link> instead of <meta> and use the 'rel' and 'href' attributes instead of the 'name' and 'content' this could easily be extended by others who don't mind getting their sleeves dirty, but I'm just after the quick and dirty solution for now.

So, this semi-patch I'm using works exactly like the regular metatags quick, except if you add a meta tag name of 'canonical' -- in which case this code generates a properly formated <link> tag instead of <meta>.

valthebald’s picture

Version: 7.x-1.0-beta4 » 7.x-2.x-dev

Moving new feature requests to 2.x

valthebald’s picture

Status: Needs review » Needs work

Marking this as 'needs work' - I'm going to implement more general approach and add new field type(s) for head elements other than regular meta tags

valthebald’s picture

Status: Needs work » Closed (duplicate)