Welcome to WebmasterWorld Guest from 54.144.79.200

Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

Add javascript to template in Genesis

     

wilkinsj

9:37 pm on Aug 10, 2014 (gmt 0)



Hi everyone

I need to add a piece of javascript code to all of the pages using a certain template. My site is running on the Genesis framework. Any idea how to do this?

Many thanks in advance
V

Planet13

4:09 pm on Aug 11, 2014 (gmt 0)

WebmasterWorld Senior Member planet13 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



Firstly, did you go to the studiopress support forums and ask this yet?

[studiopress.com...]

Secondly, do you really mean template? Or do you really mean layout?

I am guessing you mean layout (and I apologize if I guessed wrong). There is a conditional for displaying which layout is being used:

genesis_site_layout();


So if you know the name of the layout, you could do a conditional to show the javascript.

You might try something like this:

WARNING: I AM A TERRIBLE PHP CODER. USING THE FOLLOWING CODE MIGHT JENK YOUR WHOLE SITE. YOU HAVE BEEN WARNED:

<?php
$site_layout = genesis_site_layout();
if ( 'LAYOUT-NAME-HERE' == $site_layout ) {
?>

[JAVASCRIPT GOES HERE]

<?php } ?>



Again, I pull most of my php code out of my keister, and I am far too lazy to google it and see if it is the right format or not, so USE AT YOUR OWN RISK.

Chances are it is probably missing a ; or something like that somewhere.

Whatev.

I would also install the genesis simple hooks plugin so that it is easy to install this code into your template.

You might get an idea on how to do it correctly from the place where I stole this code, namely:

[billerickson.net...]

Hope this helps.

lorax

2:01 pm on Aug 12, 2014 (gmt 0)

WebmasterWorld Senior Member lorax is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



I believe the Genesis themes provide a way to add custom code to the framework via the admin interface. Look for an option called Header/Footer Scripts.

Planet13

6:48 pm on Aug 21, 2014 (gmt 0)

WebmasterWorld Senior Member planet13 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month



I believe the Genesis themes provide a way to add custom code to the framework via the admin interface. Look for an option called Header/Footer Scripts.


Yes, they do allow you to call various scripts in the header and footer areas.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month