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
Comment #1
amaria commentedAdding Issue tag
Comment #2
dave reidPlease re-check against 6.x-1.x-dev and provide a patch if you can!
Comment #3
damienmckennaI rolled amaria's change against 6.x-1.x, but it needs to be fully tested to ensure it doesn't cause any problems.
Comment #4
damienmckennaRe-rolled.
Comment #5
emposha commentedWhat you think about a solution where definition of the "NODEWORDS_META" different then zero?
Comment #6
stella commentedAbove 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.
Comment #7
damienmckennaI've committed this to v6.x-1.x, will continue to test it though.
Comment #9
amaria commentedSorry, 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!