eZ Community » Blogs » Thiago Campos Viana » Tip: Google plus one button

By

Tip: Google plus one button

Saturday 17 September 2011 8:10:36 pm

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

In this post I will show how to create a simple template for the google plus one button.

First you'll need to create a template inside your design template folder with the name "plusone.tpl". Put this content in this file:

{ezscript_require( array('ezjsc::jquery','https://apis.google.com/js/plusone.js') )}
{def $plusid=rand( 1, 1000 )
     $s=cond( is_set($size), $size, 'standard' )
}
<span id="plusone-span{$plusid}"></span>
<script language="javascript">
    <!--
    $(document).ready(
        function (){ldelim}
           gapi.plusone.render("plusone-span{$plusid}",
                {ldelim}"size": "{$s}" {if is_set($href)},"href":"{$href}"{/if} {rdelim}
                );
 
        {rdelim});
 
    -->
</script>
{undef}

Now you can use this template by using the include template operator, you can specify the size and the href attribute, please check the plusone doc for more info.

Here are some samples:

{include uri="design:plusone.tpl"}
{include uri="design:plusone.tpl" size="tall" href="http://google.com"}
{include uri="design:plusone.tpl" size="tall"}
{include uri="design:plusone.tpl" href="http://google.com"}

You can check also my post about how to create a google login module view.

Proudly Developed with from