Founds

“Like” button for Gallery2

There is a gallery2 template implementing Facebook's "Like" button for gallery2:


<div style="float:right; margin: 0;">
<script type="text/javascript"><!--
document.write('<iframe src="http://www.facebook.com/plugins/like.php?href='+escape(

{* Album links *}
{if $theme.pageType == 'album'}
	{if $theme.item.id == null }
		{* Dynamic album *}       
		{if $theme.currentPage > 1}
			'{g->url params=$theme.pageUrl arg1="page=`$theme.currentPage`" forceFullUrl=true}'
		{else}
			'{g->url params=$theme.pageUrl forceFullUrl=true}'
		{/if}
	{else}
		{* Normal Album *}
		{if $theme.currentPage > 1}
			'{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.item.id`" arg3="page=`$theme.currentPage`" forceFullUrl=true}'
		{else}
			'{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.item.id`" forceFullUrl=true}'
		{/if}
	{/if}

{* Photo links *}
{elseif $theme.pageType == 'photo'}
	'{g->url arg1="view=core.ShowItem" arg2="itemId=`$theme.item.id`" forceFullUrl=true}'

{* Module links *}
{elseif $theme.pageType == 'module'}
	{if $theme.moduleTemplate == 'modules/comment/templates/AddComment.tpl' }
		'{g->url arg1="view=comment.AddComment" arg2="itemId=`$theme.item.id`" forceFullUrl=true}'
	{elseif $theme.moduleTemplate == 'modules/comment/templates/ShowAllComments.tpl'}
		'{g->url arg1="view=comment.ShowAllComments" arg2="itemId=`$theme.item.id`" forceFullUrl=true}'
	{elseif $theme.moduleTemplate == 'modules/search/templates/SearchScan.tpl'}
		'{g->url arg1="view=search.SearchScan" arg2="form[useDefaultSettings]=1" forceFullUrl=true}'
	{else}
		'{g->url params=$theme.pageUrl forceFullUrl=true}'
	{/if}

{* All other links *}
{else}
   '{g->url params=$theme.pageUrl forceFullUrl=true}'
{/if} 

)+'&layout=button_count&show_faces=true&width=112&action=like&font=tahoma&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:112px; height:21px;" allowTransparency="true"></iframe>');
//-->
</script>
</div>

Write this code into like.tpl file and put this file into templates/local subdirectory of your gallery2 theme. Then, copy theme.tpl file into the same subdirectory (if you haven't had done it before) and edit it putting the following code in an approriate place:


      {if  $theme.pageType != 'admin'}
	{g->theme include="like.tpl"}
      {/if}

An example of this button you can see in the "Photos of Sochi" gallery (in the top right corner of page).