Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
I have a custome template made (node..template.tpl.php) do display a custom content type named template.
What is the php code to print the sharethis links on this file?
Drupal7
Comments
Comment #1
Gaofengzzz CreditAttribution: Gaofengzzz commentedYou can try to use
in template file.
Comment #2
Gaofengzzz CreditAttribution: Gaofengzzz commentedComment #3
spv CreditAttribution: spv commentedNope didnt print anything actually.... any other thoughts?
Comment #5
spv CreditAttribution: spv commentedPosted this over a year ago never found a solution..... how do we paste the share this code in a custom page template so that it shares that exact page.....
Comment #6
leidyran CreditAttribution: leidyran commentedI guest you can try the following:
$node = node_load($nid);
$links = sharethis_node_view($node, 'full', 'en');
print('
');
Comment #7
glewe CreditAttribution: glewe commentedJust use this (Drupal 7):
<?php print render($content['sharethis']); ?>
Comment #8
Rishi KulshreshthaFor Drupal 8 just use:
{{ content.sharethis }}
to print the sharethis widget via your
node.html.twig
or similar.Comment #9
lejager CreditAttribution: lejager at Aten Design Group commented#6 by leidryan worked for me.
Here's an example in a THEME_preprocess_page(), adding the share links to the sidebar.
Comment #10
AswathyAjish CreditAttribution: AswathyAjish commented#1 worked for me. Thanks.