Sorry if this is a duplicate. I could not find it in any of the issues.

I'm using the api to create a custom template for my tags. For example...
'tag:template' => array('my_tag' => '<meta property="%name" content="%content"%attributes />'),
However it always defaults to the NODEWORDS_META template.

There is a problem in the nodewords.module code at around line 1145 where you do the switch on the template...

        switch ($template) {
          case NODEWORDS_META:
            $template = '<meta name="%name" content="%content"%attributes />';
            break;

          case NODEWORDS_HTTP_EQUIV:
            $template = '<meta http-equiv="%name" content="%content"%attributes />';
            break;

          case NODEWORDS_LINK_REL:
            $template = '<link rel="%name" href="%content"%attributes />';
            break;

          case NODEWORDS_LINK_REV:
            $template = '<link rev="%name" href="%content"%attributes />';
            break;

          default:
            if (!is_string($template)) {
              $template = '';
            }
            break;
        }

Since switch does loosely coupled comparison, if $template is a string it will choose the NODEWORDS_META case instead of the default case.

I did the following to fix it...

        if (!is_string($template)) {
          switch($template) {
            ......
          }
        }

Can this be fixed in the next release?

Comments

amaria’s picture

Issue tags: +v6.x-1.12 blocker

Adding Issue tag

dave reid’s picture

Version: 6.x-1.11 » 6.x-1.x-dev

Please re-check against 6.x-1.x-dev and provide a patch if you can!

damienmckenna’s picture

Status: Active » Needs review
StatusFileSize
new2.29 KB

I rolled amaria's change against 6.x-1.x, but it needs to be fully tested to ensure it doesn't cause any problems.

damienmckenna’s picture

StatusFileSize
new1.79 KB

Re-rolled.

emposha’s picture

What you think about a solution where definition of the "NODEWORDS_META" different then zero?

stella’s picture

Status: Needs review » Reviewed & tested by the community

Above patch works well for me.

Btw, the meta tag type in this example is an Open Graph tag (and for various reasons I don't want to use the opengraph_meta - doesn't have enough functionality). Perhaps you could also consider adding this as one of the default templates.

damienmckenna’s picture

Status: Reviewed & tested by the community » Fixed

I've committed this to v6.x-1.x, will continue to test it though.

Status: Fixed » Closed (fixed)

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

amaria’s picture

Sorry, I kinda abandoned this. I just made the change locally and moved on because I had so-oooo much work to do. But thanks Damien for getting it into a release!