By hmdnawaz on
I want to add facebook like button to my page. I wrote the following code. It works fine.
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like show_faces="true" width="450"></fb:like>
But i want to add the button through drupal_add_js() function. I wrote the following code but it did not work.
$myscript1 = '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>';
echo drupal_add_js($myscript, 'inline');
What is the problem here?
[Edited to add <code> and </code> tags: nevets]
Comments
Where did you put the
Where did you put the code?
There should be no 'echo' before drupal_add_js()
And where do you add the
<fb:like show_faces="true" width="450"></fb:like>, it is not shown in the second part.Where should i place the <fb:like
Where should i place the
<fb:like show_faces="true" width="450"></fb:like>.I wrote this code while creating a page.
Ahmad Nawaz
Acquia Certified Developer
Email: hmdnawaz@gmail.com
Skype: hmdnawaz
If someone have idea about this
If someone have idea about this please help me.
I am waiting for your replies.
Ahmad Nawaz
Acquia Certified Developer
Email: hmdnawaz@gmail.com
Skype: hmdnawaz
Only one year to the answer...
You have the basic idea right, but are just a bit off with your execution:
The above will add the fb javascript to your pages... and if you are clever, you will have some type of IF statement to only add them when needed (like using hook_nodeapi() in D6 or hook_entity_prepare_view() in D7... or in preprocess for your theme)
However, you still need to add the code for displaying the like box:
This could just be added to your theme OR (even better) add it to a block and then you can stick it wherever you like.
regards,
Ron Northcutt
Directory of Technical Marketing, Acquia
Here's a theme based approach
1) in template.php I added this function... (don't forget to escape your quotes, the filter here is stripping that out for some reason)
2) in my node.tpl.php I added this code...