Jump to content

Facebook like button in generic php


hefterbrumi

Recommended Posts

Hello!

 

I need a little help here please!

 

This is the end of the code on a page. It shows a pic with a gallery assigned to it. I want to attach a facebook like button to the pic, not the gallery.

Since its a dynamic page I modified the like button code. But for some reason I just cant fit it in. Im kind of a novice and i didnt write this code on my own:) Oh and yes I coud stick the code right into the webpage, but its a generic site so i cant do it on every single page. So how do you say in "PHP" to put "this" on the page in "this" div tag, and where do you put it in to work properly?

 

 

....

 

$res.="<div class=\"works\">

<div class=\"worksleft\">

  <div class=\"worksimg\">

  <img src=\"<resource>".$img["name"]."</resource>\" width=\"".$img["x"]."\" height=\"".$img["y"]."\" alt=\"".$mass["xtitle"]."\" title=\"".$mass["xtitle"]."\" >

  </div>

<div class=\"workstxt\">".$tit."</div>

</div>

<div class=\"worksright\">

".$gal."

</div>

<div class=\"clear\"></div>

".$desc."

</div>";

}

 

 

$result[0]["head"]="";

$result[0]["body"]=$res;

return($result);

}

 

....

 

 

 

and this is the code i have to put in:

 

 

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php  echo "http://" . $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>&layout=button_count&show_faces=false&width=450&action=like&font&colorscheme=dark&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:21px;" allowTransparency="true"></iframe>

 

 

thanks very much in advance!

Link to comment
Share on other sites

So you're asking how to make it easy to insert this into each page?  The easiest way is to put it in your page footer file which is a file people use to end all of their pages the same way.  My footers usually have the copyright information div and </body></html> tags and all that sort of thing and then at the bottom of every page I just "include" that file:

 

<?php include('footer.php'); ?>

 

As long as the footer.php file includes your facebook code there, it will insert anywhere you put the include tag I just gave you, to include the in the middle of a div.  Hell, if you want you can make the include file have the div start and end within the file and just insert it, whatever you want.  Is this what you were looking for?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.