Closed (fixed)
Project:
AddToAny Share Buttons
Version:
7.x-4.9
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
11 Jun 2012 at 12:58 UTC
Updated:
24 Jun 2019 at 14:33 UTC
Jump to comment: Most recent
Comments
Comment #0.0
sgurlt commentedAdd info
Comment #0.1
sgurlt commentedAdd info
Comment #1
gregory claeyssens commentedTry it like this:
Comment #2
m.lebedev commentedNot working social links in modal. addtoany module is not initialized
Comment #3
Media Crumb commentedtrying this on a page template doesnt work. Anyway to get this to work on page templates?
Comment #4
JRF commentedI've noticed that the buttons don't appear on templates that don't include :
print render($page['content']);If someone can explain me why there is this dependency ? (and how can I remove it ?)
Comment #5
rooby commentedIf you are using the built in node functionality you can do this in your node template file:
Put this in your file somewhere above the line that does
print render($content);:Then wherever you want to print the buttons do this:
If you want to print the block somewhere you can use the information at https://www.drupal.org/node/26502
The short version of that is...
To print just the block contents:
To print the full block with block title, using the proper block template:
I would generally use the latter version.
Also, if you just want to print the buttons markup somewhere but not use the block you can apply the patch at #2542488: Make _addtoany_create_button() non-private and split out node specific functionality and do this for the current page:
Or this for a specific page:
Or an external URL:
Comment #6
rooby commentedComment #7
rooby commented@JRF re #4:
Because the addtoany buttons are added to the node content and the default for the node template is to print
print render($page['content']);to print all content at once.See my comment #5 for info on how to stop printing it there and print it manually elsewhere.
Comment #8
rooby commentedI think #5 covers it.
Let me know if it doesn't
Comment #10
skribbz14 commentedMy problem turned out to be that you cannot print the addtoany block within the page.tpl.php, but you can in the node.tpl.php. Heads up to anyone trying to figure out why these answers aren't working for them!
Comment #11
abarpetia commented#10: thanks for heads up. You also need to change placement setting on the configuration. For ex: #5 work around will only work if you have "display in content section" check box ticked. If you have "Display in link section" then you need to put this code above
print render($content['links']);this.Does any one got this working in page.tpl.php? I have a requirement to put this button into different region of page.tpl.php.
***UPDATE***
Got this working in page.tpl.php. Following are steps
print render($content);:Standalone Service Buttons
Comment #12
rooby commented@abarpetia:
Also see my comment #5 regarding the addtoany_create_buttons() function, which no longer requires a patch to use.
Comment #13
bobby endarr ramdin commentedTWIG node file
{{ content.addtoany }}
Comment #14
halthFor anyone landing in here and even maybe trying to accomplish it in a different way, make sure you're rendering
$page['content'];to the node's corresponding page template file:print render($page['content']);Addtoany attaches it's javascripts to the page's (not node's) content element: