понедельник, 28 декабря 2015 г.

Adding Facebook 'Like' button to multiple pages Joomla Site


Adding Facebook 'Like' button to multiple pages Joomla Site

Postby JoomlaProf » Mon Jul 18, 2011 9:22 pm
Adding Facebook 'Like' or 'Recommendations' to your Joomla websites can easily be achieved by inserting the iframe tagged code onto your html template using the admin panel. Another method is to depict 'Like' on a module far the center of attention. To this end you may find an appropriate plugin in the extension directory.

However if you like to get the 'Like' button closer to the action then you may interweave the code into the template or that part of the component which will be called dynamically.When dealing with numerous webpages the task tends to become tricky and tedious. To further complicate things, lack of properly documented functions could keep you guessing your time away.In this post we will look at how we can effectively add Facebook apps to our Joomla website to accommodate the numerous dynamic pages that Joomla generates.

Adding the Like button - iframe

To add a 'Like' button simply visit the Like Button Plugin fill out the form push the Get Code button and copy the iframe to the appropriate area in your joomla template.
If you do have numerous pages whose url is required to be parsed, this piece of static code could use a hack.To elaborate the this point, consider a Game Site with the largest number of Online Games 36,000 at the time of this writing.Imagine filling out the Like form and pasting the code on 36,000 individual games.

Coding becomes really simple if we hack the
    href=http://myurl.com
piece and substitute it with a variable
    $myabsoluteurl
We can then look up the url and parse it to the variable.

A simple method to get the current url is
    $url = JURI::current();
    $currenturl = $url;

this is not effective when parsing through an iframe. An appropriate hack around this would be
    $myabsoluteurl=JURI::getInstance()->toString();
    echo $myabsoluteurl.'"';

Your complete functional iframe thus looks like this
CODE: SELECT ALL
<iframe src="https://www.facebook.com/plugins/like.php?href=<?php $myabsoluteurl=JURI::getInstance()->toString(); echo $myabsoluteurl.'"'; ?>&amp;  scrolling="no" frameborder="0"
        style="border:none; width:450px; height:80px"></iframe>

There we have a simple iframe that will post your Likes,dynamically.
JudeSecaro
Posts: 3
Joined: Sun Jul 17, 2011 7:15 pm

Re: Adding Facebook 'Like' button to multiple pages Joomla S

Postby JudeSecaro » Tue Jul 19, 2011 7:43 am
Nice Post. I tried using prependmeta tags to handle the OpenGraph interface Facebook adopts but get an error that <meta name="XYZ" instead of <meta property="XYZ". Is there a way to throw a <meta property="XYZ"?
JohnS
Posts: 2
Joined: Fri Aug 19, 2011 9:43 am

Re: Adding Facebook 'Like' button to multiple pages Joomla S

Postby JohnS » Fri Aug 19, 2011 9:53 am
I have added the facebook recomendations tab to my site and it works however with default images. Would like to understand how Joomla sites can be customised to interact with facebook through the opengraph protocol. Does Joomla support the Opengraph protocol....have looked through a number of extensions on the community but did not come across one on the open graph protocol.

FaceBook Recommendations Frame
CODE: SELECT ALL
<iframe src="http://www.facebook.com/plugins/recommendations.php?site=MYSITE.com&width=550&height=750&header=false&colorscheme=dark&font&border_color" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:550px; height:750px;" allowTransparency="true"></iframe>
JoomlaProf
Posts: 2
Joined: Fri Aug 19, 2011 11:11 am

 Facebook OpenGraph On Joomla site

Postby JoomlaProf » Fri Aug 19, 2011 10:18 am
JohnS wrote:I have added the facebook recomendations tab to my site and it works however with default images. Would like to understand how Joomla sites can be customised to interact with facebook through the opengraph protocol. Does Joomla support the Opengraph protocol....have looked through a number of extensions on the community but did not come across one on the open graph protocol.

FaceBook Recommendations Frame
CODE: SELECT ALL
<iframe src="http://www.facebook.com/plugins/recommendations.php?site=MYSITE.com&width=550&height=750&header=false&colorscheme=dark&font&border_color" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:550px; height:750px;" allowTransparency="true"></iframe>


Facebook Open Graph Protocol on Joomla

Open graph protocols are easily implementable on Joomla by stringing together the tag meta properties as a string and parsing to the header using
    addCustomTag()

The customised code will first call a string variable which simply stitches the various meta property tags. The following is an example implemented on gaming portal Y9
    $opengraph = '<meta property="og:title" content="'.$game->title.'"/>' ."\n";
    $opengraph .= '<meta property="og:type" content="'."BLOG_replacewithyourtype".'"/>' ."\n";
    $opengraph .= '<meta property="og:url" content="'. $myabsoluteurl.'"/>' ."\n";
    $opengraph .= '<meta property="og:image" content="'."http://YOURSITE.com/.../images/".$blog->imagename.'"/>' ."\n";
    $opengraph .= '<meta property="og:site_name" content="'."YOUR SITE TITLE".'"/>' ."\n";
    $opengraph .= '<meta property="fb:admins" content="'."YOUR FACE BOOK DEVELOPER CODE".'"/>' ."\n";

you can also crosscheck functioning with recommendations frame above in Y8
CODE: SELECT ALL
$opengraph    = '<meta property="og:title" content="'.$game->title.'"/>' ."\n";
            $opengraph .= '<meta property="og:type" content="'."BLOG_replacewithyourtype".'"/>' ."\n";
            $opengraph .= '<meta property="og:url"  content="'. $myabsoluteurl.'"/>' ."\n";
            $opengraph .= '<meta property="og:image" content="'."http://YOURSITE.com/.../images/".$blog->imagename.'"/>' ."\n";
            $opengraph .= '<meta property="og:site_name" content="'."YOUR SITE TITLE".'"/>' ."\n";
                                $opengraph .= '<meta property="fb:admins" content="'."YOUR FACE BOOK DEVELOPER CODE".'"/>' ."\n";
//add the tags to the head of the page;[/
$document->addCustomTag($opengraph);

0 коммент.:

Отправить комментарий