GetSimple Support Forum

Full Version: Adding something to <head> on individual pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to do this or perhaps a plugin that accomplishes it? I have a specific page on which I want to use a Javascript image gallery, but I don't want to link the script on all the pages, just the photo gallery.

I know I could create a second copy of the main template, but that's not very elegant (and now I'd have to make every change to the template twice).
Yes, it would be possible. But it might be easier to just set up a custom field in the page editor, that way you have it in place for the future if you want to add anything to the HEADs of other pages.
Thanks for the suggestion. At first, I had all sorts of problems with escape characters showing up in the generated HTML, but then I realized I could just narrow it down to the link itself. I finally used this in the header:

Code:
<script language="javascript" src="<?php getCustomField('headerjs'); ?>"></script>

Not 100% elegant as it's extraneous markup on pages that don't use any JS, but it works.
How about only adding the SCRIPT-element when the headerjs field for the page has actually been filled with something?
Code:
<?php
   if (strlen(returnCustomField('headerjs'))>0) {
      echo '<script language="javascript" src="'.returnCustomField('headerjs').'"></script>';
   }
?>