GetSimple Support Forum
Adding something to <head> on individual pages - Printable Version

+- GetSimple Support Forum (http://get-simple.info/forums)
+-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3)
+--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16)
+--- Thread: Adding something to <head> on individual pages (/showthread.php?tid=696)



Adding something to <head> on individual pages - StateStreet - 2010-05-25

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).


Adding something to <head> on individual pages - Zegnåt - 2010-05-25

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.


Adding something to <head> on individual pages - StateStreet - 2010-05-27

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.


Adding something to <head> on individual pages - Zegnåt - 2010-05-27

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>';
   }
?>