0
Welcome Guest! Login
0 items Join Now

How to add a custom j-script to gantry with an on/off toggle

    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    How to add a custom j-script to gantry with an on/off toggle

    Posted 14 years 7 months ago
    • Here is an example for a feature that adds a custom with a on/off toggle that you can set per menu-item.

      1. Be sure your have the script in the js-folder of your template.
      in my example it should have the name "customscript.js"

      2. download the file I have attached and copy it into the features folder of you template.

      3. add this to your templateDetails.xml
      <param name="customscript-enabled" type="toggle" default="1" label="customscript" description="customscript" setinmenuitem="true" />
      </params>

      (note for Gantry4/Joomla 2.5+ this needs to be a different)

      to add more than one script change in the file
      $gantry->addScript("customscript.js");
      to
      $gantry->addScript(array('customscript.js', 'customscript2.js'));
  • Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 14 years 4 months ago
    • Hi Henning,

      I would need to add a custom script code to 1 rocketheme template, because I have 2 domains pointing at it (same hosting and same folder) 1 is country code free domain .hr extension which every company in croatia gets free and 1 is a commercial one. gmaps doent work then just on one API key... so I have found I should use a custom script like:
      <script type="text/javascript"> document.write(
             '<script src="http://maps.google.com/maps?
      file=api&amp;v=2&amp;key=' +
             {
                 'example.com': 'api-key-for-example.com',
                 'anotherexample.com': 'api-key-for-anotherexample.com'
             }[location.host] +
             '" type="text/javascript"><\/script>' );
          </script>

      to get this working.... do you think this is posssible and should I use the technic you have described here? or is there a easier way (like in other templates) to add custom code to a index.php file that will show it on all pages?

      P.S. I would only like to have it on the our location page....
  • Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 12 years 4 months ago
    • Hallo Henning, wie gehts?

      Anyway... with regards to this somewhat older post... how would I do this for j 3.0? I'm assuming the difference is only parameters to fields?

      What I wish to do is integrate an external js into j 3.0 and gantry with a toggle enable disable as a feature. I should say in advance the js I wish to use is firefiy.js that is a free script and is also used in other templater makers sites for joomla. Anyway, I wish to use this effect within Gantry (metropolis theme).Can you please tell me how?
    • Android's Avatar
    • Android
    • Newbie
    • Posts: 4
    • Thanks: 0

    Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 12 years 3 weeks ago
    • "to get this working.... do you think this is posssible and should I use the technic you have described here? or is there a easier way (like in other templates) to add custom code to a index.php file that will show it on all pages?

      P.S. I would only like to have it on the our location page...."

      No answer to this in so long?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 12 years 3 weeks ago
    • if you just want to add a custom script
      I would just add
      <?php $gantry->addScript("customscript.js"); ?>
      to the index.php
    • bitfix's Avatar
    • bitfix
    • Jr. Rocketeer
    • Posts: 33
    • Thanks: 0

    Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 10 years 10 months ago
    • Henning wrote:
      if you just want to add a custom script
      I would just add
      <?php $gantry->addScript("customscript.js"); ?>
      to the index.php

      Hi Henning,

      I have a js code i need to add to the site. So what i need to do is put that file in the themes js folder, open the theme (oculus) index.php and add: <?php $gantry->addScript("customscript.js"); ?> in between the html tags

      ...and i'm good to go?
    • Henning's Avatar
    • Henning
    • Preeminent Rocketeer
    • Posts: 29362
    • Thanks: 954
    • Volunteer

    Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 10 years 10 months ago
    • add it in the head tag
    • bitfix's Avatar
    • bitfix
    • Jr. Rocketeer
    • Posts: 33
    • Thanks: 0

    Re: How to add a custom j-script to gantry with an on/off toggle

    Posted 10 years 10 months ago
    • Head tag, of course... typo ;)

      Thx for confirming :)

Time to create page: 0.067 seconds