Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I think no only
<?php $share = module_invoke('addtoany', 'block_view', 'addtoany_button');
print render($share['content']); ?>
is required.
If I just embedding block in my template, many other rows of code aren't uppearing:
in header:
@import url("http://mysite/sites/all/modules/addtoany/addtoany.css");
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var a2a_config=a2a_config||{},da2a={done:false,html_done:false,script_ready:false,script_load:function(){var a=document.createElement('script'),s=document.getElementsByTagName('script')[0];a.type='text/javascript';a.async=true;a.src='http://static.addtoany.com/menu/page.js';s.parentNode.insertBefore(a,s);da2a.script_load=function(){};},script_onready:function(){da2a.script_ready=true;if(da2a.html_done)da2a.init();},init:function(){for(var i=0,el,target,targets=da2a.targets,length=targets.length;i<length;i++){el=document.getElementById('da2a_'+(i+1));target=targets[i];a2a_config.linkname=target.title;a2a_config.linkurl=target.url;if(el)a2a.init('page',{target:el});da2a.done=true;}}};a2a_config.tracking_callback=['ready',da2a.script_onready];
//--><!]]>
</script>
in footer:
<script type="text/javascript">
<!--//--><![CDATA[//><!--
da2a.targets=[
{title:'my page title',url:'http://mysite/mypage'}];
da2a.html_done=true;if(da2a.script_ready&&!da2a.done)da2a.init();da2a.script_load();
//--><!]]>
</script>
how can I embed a block with all this rows of code automatically? May be some magic in template.php?
Comments
Comment #1
LoyC CreditAttribution: LoyC commentedI need this to
Comment #2
sgurlt CreditAttribution: sgurlt commentedSubscribing !
Comment #3
Jovean CreditAttribution: Jovean commentedTry adding this to your code just before the module_invoke:
Comment #4
Jody LynnComment 3 is useful.
I use the following hook_init implementation to make sure this is set on my nodes, allowing me cache the pages.
Comment #5
hugues.esslinger CreditAttribution: hugues.esslinger commentedI try Comment 3 and 4...
But not working for me...
Can I forced to load add to any and initializ it ?
Comment #6
atif.kht CreditAttribution: atif.kht commentedCan anyone post a complete solution to this one?
Comment #7
standingtall CreditAttribution: standingtall commentedsubscribing!!
Comment #8
rooby CreditAttribution: rooby commentedFor people where this isn't working for you are you using version 3 or version 4 of the module?
If version 3 you should update to version 4 because 3 is not supported any more.
Version 4 really should work without you having to do anything unusual like set global variables but I will try it out when I get a chance and see.
Comment #9
permanaj CreditAttribution: permanaj commentedI'm using version 4. Tried #3 also not working.
At first call, it shows, but after I do some configruation, it didn't show anymore.
Comment #10
NIKS_Artreaktor CreditAttribution: NIKS_Artreaktor commentedInteresting thing.
If you create the same addtoany block content
But change style
a2a_target
to
a2a_default_style
It is working - even if you create simple html code of generated addtoany list.
Comment #11
maxf4 CreditAttribution: maxf4 as a volunteer and commentedOn my new site drupal 7
I workaround the issue simply adding this code in my node type
this works!
Hope could be of help for someone
Comment #12
halthMake 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:
Comment #13
micropat CreditAttribution: micropat commented