I am trying to figure out how to place the button on a custom node page for a content type ("Artists"). I set the correct content type, set the permissions, selected the second option for displaying a cck-like field, but how do I place this into my custom "Artists" layout, or node-artists.tpl.php?

I am looking for something like

<?php print $fb-connect-like ?>

Thanks!

Comments

nagarajanl’s picture

Hello,

If i understand correctly, you can do this by placing the button in the template_preprocess_node() and put it in your 'node-artists.tpl.php'. For ex)

function themeName_preprocess_node(&$variables) {

$variables['fb-connect-like'] = "" ; // place your button code here....
}

Now you can print the variable print $fb-connect-like in your 'node-artists.tpl.php'

sammyman’s picture

Thanks for the quick response. I can't seem to find what the code for the button would be for this module?

nagarajanl’s picture

I think the best solution may be add the hook_form_alter for this corresponding form and place the button there by coding something like...

function hook_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'your_form_id') {
$form['customSubmit'] = array('#type' => 'submit', '#value' => 'Submit');
}

}

Not sure this what you want...

sammyman’s picture

This looks like it will work. I still haven't figured out how to post the correct url for the button. I am trying to use this in my theme-settings.php file:

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php urlencode(the_permalink()); ?>&amp;layout=standard&amp;show-faces=false&amp;width=450&amp;action=like&amp;font=lucida+grande&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:30px; display:block;"></iframe>

This also makes me wonder why I am using a module??? Looks like I am just working bypassing the module completely. Or am I?

ferdi’s picture

A couple of options:

<?php print($node -> content['fb_social_like_widget']['#value']); ?>

or

<?php $url = url($node_url, array('absolute' => TRUE)) ?>
<?php print theme('fb_social_like_widget', $url); ?>

or

<?php $url = url($node_url, array('absolute' => TRUE)) ?>
<fb:like layout="button_count" href="<?php print $url; ?>"></fb:like>
sammyman’s picture

I tried each one without success. Then I tried all 3, without success.

I know other facebook apps are incompatible, and I am using facebook connect. Could that be why I am not seeing any like buttons?

sammyman’s picture

Ok, it does now work when I disabled the facebook connect. BTW, option #2 above does not work, but the top and bottom ones did work well.

cem kaan’s picture

I used third one in node.tpl.php with facebook connect it works.

<div class="facelike">
      <?php $url = url($node_url, array('absolute' => TRUE)) ?>
      <fb:like font="verdana" href="<?php print $url; ?>"></fb:like>
      </div>
radiofranky2009’s picture

Hi,
I tried your code in a block, but it doesn't seems to be working. Is there something else need to be set when dealt with blocks?
this is what I tried.

print($node -> content['fb_social_like_widget']['#value']);

When it's posted in .tp file, yes it works. However, the only way for this to show is to enable in the settings print($node -> content['fb_social_like_widget']['#value']); but then if you place one at your own you will have two places showing "like".

Is there a way without editing the module to show only where i want to show and without displaying the default one?
Right now I have two places showing "like". First one is the default place which is on the top of the node, and the 2nd one is the one I placed.

thanks very much.

yaho’s picture

Hi, how to print fb social comment in my own node.tpl.php?

It works good until I remove $content.

Now, I have only standard drupal comment.

Thanks! :-)

ferdi’s picture

Status: Active » Fixed

See #5

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.