Drupal.
I've worked on Drupal 6 and there does not seem to be any module to do it.
But you can very simply do it by adding in the theme page.tpl.php.
Don't use drupal_add_js in page.tpl.php as it does not seem to work. I added even in template.php but did not work.
Just go to <your-theme>/page.tpl.php and add the desired code
just before this code at the bottom of the file:
<?php print $closure ?> </body> </html>
Now just go to admin/build/themes and click configure on the default theme and Save it once so that your site's theme cache is recreated.
No need to display Infolink code for Admin
If you don't want the infolink code to be displayed for admin then wrap the code as in below. If you don't want to display only for anonymous users then simply check $user->uid>0 instead of :
global $user;
if( $user->uid != 1)
{
//Your javascript code
}
Integration for multi-site setup
Do you have same files sharing multiple drupal sites? Then integrate the Javascript code in the same page.tpl.php using the following technique:
<?php
{
global $base_root;
global $user;
if( $user->uid != 1 && strstr($base_root,"site1.com") )
{
print<<<EOT
<script type="text/javascript">
var infolink_pid = 325111;
var infolink_wsid = 4;
</script>
<script type="text/javascript" src="http://resources.infolinks.com/js/infolinks_main.js"></script>
EOT;}
else if( $user->uid != 1 && strstr($base_root,"site2.com") )
{
print<<<EOT
<script type="text/javascript">
var infolink_pid = 325111;
var infolink_wsid = 5;
</script>
<script type="text/javascript" src="http://resources.infolinks.com/js/infolinks_main.js"></script>
EOT;}
else if( $user->uid != 1 && strstr($base_root,"site3.com") )
{
print<<<EOT
<script type="text/javascript">
var infolink_pid = 325111;var infolink_wsid = 3;
</script>
<script type="text/javascript" src="http://resources.infolinks.com/js/infolinks_main.js"></script>
EOT;}
}?>
No comments:
Post a Comment