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.
When developing the new version of the module, and adding support for the HTML5 tag, I noticed that it didn't work as expected. The specification of Google Plus one +1 API http://code.google.com/apis/+1button/#plusonetag says:
An HTML5 equivalent syntax is available as follows:
The class must be set to g-plusone. Any included attributes need to be prefixed with data- such as data-size.
The attributes are not recognized. BUT, if the tag has the attributes without the 'data-' string, it will work. So the example will be:
I will update this issue if there is any update from Google +1 team.
Comments
Comment #1
corbacho CreditAttribution: corbacho commentedUps.. filter removed the code:
Again. This is the current documentation, with HTML5 valid "data-" attributes
and this how it would work:
Comment #2
ernestd CreditAttribution: ernestd commentedNote that Google fixed the bug yesterday where data attributes were not recognized. Therefore the workaround described here will break now but not the one with data attributes.
Comment #3
corbacho CreditAttribution: corbacho commentedYeah that happened. I fixed so the last recommended versions of 6.x and 7.x branch has the valid HTML5 attributes already.
Still I see some weird behaviors with the HTML5 syntax. I will test further tomorrow.. so I recommend the g:plusone syntax in the meanwhile.
Also I notice that google doesn't let you anymore to "fool" the href of the button. For example in the admin settings there is a a demo button pointing the href to "http://drupal.org". It was working before showing a counting > 60 last time I saw. But not today anymore.
Comment #5
Mac_Weber CreditAttribution: Mac_Weber commentedIt is still not validating as HTML5 http://html5.validator.nu
Is that href really necessary there?
Comment #6
corbacho CreditAttribution: corbacho commentedThe href attribute It's not "needed". If you omit it, then Google will take the URL of the page dynamically via Javascript. BUT, there is edge cases, as always:
So, there is no problem when you are in a node-page, because the node URL corresponds to the URL of that page.
But this is not the case when Drupal displays more than one node in a single page (frontpage, search results, taxonomy term page, etc )
That's why href is needed. To say explicitly "hey, this is the URL of the thing you are +1'ing'"
The good news are that diving in the Forums I found the data-href should work too, making the HTML5 valid. Now seems obvious to me, but I didn't think about prefixing the href attribute with data-
So I will test it and soon will be uploaded.
Thanks for the report Mac
Comment #7
Mac_Weber CreditAttribution: Mac_Weber commentedYou are welcome, corbacho. Congrats for the module and active development.
Comment #8
agoradesign CreditAttribution: agoradesign commentedYou definitely have to change it to data-href, because it's the only way that works -> http://drupal.org/node/1206098#comment-4689002 :-)
Comment #9
corbacho CreditAttribution: corbacho commentedAllright, this is important then. Last night I already pushed that change to 7.x dev branch. Later today I will do same for 6.x and create releases for both.
Thanks
Comment #10
CD CreditAttribution: CD commentedDoes this module version 7.x-1.3 now work with Drupal 7 HTML5 sites?
I have a responsive drupal site that I need to add google plus 1 button to.
Let me know :)
Comment #11
corbacho CreditAttribution: corbacho commentedyes @CD, the module supports HTML5 format of the button.
There were some issues in the early days, when Google released the G+ button but it was solved 3 years ago :)
Comment #12
CD CreditAttribution: CD commentedWow, that was quick, thanks Corbacho!
I'll let you know if my installation works okay :)
Comment #13
CD CreditAttribution: CD commentedHi Corbacho,
It works fine with what it is designed to do, e.g., it displays just fine on view teaser full content etc.
The one place I would also like it is with Taxonomy views but it doesn't have an option for this I can find. I tried to select everything, but it had no effect.
Is there an option for this, can I request if not for next issue.
Comment #14
corbacho CreditAttribution: corbacho commentedThere is no Views integration still. See https://www.drupal.org/node/1223728