Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
I'm working on a module which will allow integration with Open Graph protocol. During implementation I found a problem with some code from the nodewords api:
function opengraph_nodewords_tags_info() {
$tags = array(
'opengraph_type' => array(
'tag:context:allowed' => array(
NODEWORDS_TYPE_NODE,
NODEWORDS_TYPE_PAGE,
),
'tag:function:prefix' => 'nodewords_opengraph_type',
'tag:template' => array(
'og:type' => NODEWORDS_META,
),
'widget:label' => t('Open Graph - Type property tag'),
'widget:permission' => 'edit Open Graph - Type property tag',
),
);
return $tags;
}
.....
function nodewords_opengraph_type_prepare(&$tags, $content, $options) {
if (!empty($content['value'])) {
$tags['opengraph_type:og:type'] = $content['value'];
} else {
//testing stuff
drupal_set_message("no luck");
}
}
If I change the following lines to something other than "og:type" to something like "og;type", it will come out fine. How can I escape the colon so that it print's out in the meta information? The following lines should work, but I believe parsing is not being done correctly. I'm hoping and expecting a simple fix.
$tags['opengraph_type:og:type'] = $content['value'];
'tag:template' => array(
'og:type' => NODEWORDS_META,
),
Comment | File | Size | Author |
---|---|---|---|
#2 | nodewords_opengraph.zip | 3.44 KB | mgenereu |
Comments
Comment #1
stevesmename CreditAttribution: stevesmename commentedA couple things I see is that line 1101 in the nodewords.module strips out the colons in names and explodes them out.
$parts = explode(':', $name);
I also see that nodewords module strictly deals with name meta tags and not additional tags like 'property' which is what Open Graph requires. http://developers.facebook.com/docs/opengraph#extra-data
<meta property="fb:admins" content="USER_ID1,USER_ID2"/>
Unless there is not a road map allowing additional tags like 'property' be available within the nodewords module then it's best to move on integrating this module with another module instead.
Comment #2
mgenereu CreditAttribution: mgenereu commentedI created an Open Graph Nodewords module as well. It's tossed together just to get the job done and would like to see made part of the Nodewords project so that it can continue to mature. I had to change two things in the main Nodewords module to make it work:
1. The explode thing mentioned above is just not compatible and I can't find any reason anywhere in the docs as to why it does it. Looks like an over complication of the API for namespaces or something but nothing else chokes on names with colons other than this one output location.
Replaced:
With:
2. Increase the template constants by one because the case statement where these are used were returning true when NODEWORDS_META's value of 0 was compared to my provided templates that use "property" instead of "name". This is more of bug fix to nodewords.module to get its custom template support working.
This is live in production and successfully working. Anybody who wants to help make this more than an attachment in an issue, please let me know what I can do to help!
Comment #3
Whackler CreditAttribution: Whackler commentedNice, thanks!
I can see myself entering an opengraph image for each page on my site, but the title and url ?
Can tokens be used or something else to automate this ?
Comment #4
lolandese CreditAttribution: lolandese commentedRelated.
Comment #5
toomanypets CreditAttribution: toomanypets commentedPosted a custom module for adding Open Graph protocol meta tags here:
http://drupal.org/node/784904#comment-3582838
Comment #6
Dave ReidMerging this issue into #803512: Support Open Graph Protocol meta tags since we don't need two issues for supporting Open Graph meta tags.
Comment #7
nitin_kumar CreditAttribution: nitin_kumar commentedThanx for add attachment, works fine for me.
Comment #8
DamienMcKenna