Adding Variables to JavaScript in Joomla

Posted by Vikram on Stack Overflow See other posts from Stack Overflow or by Vikram
Published on 2011-01-11T09:49:02Z Indexed on 2011/01/11 9:53 UTC
Read the original article Hit count: 186

Filed under:
|
|
|
|

Hello friends!

This is the script I am using to display an accordion in my Joomla site:

<?php
defined('JPATH_BASE') or die();
gantry_import('core.gantryfeature');
class GantryFeatureAccordion extends GantryFeature {
    var $_feature_name = 'accordion';
    function init() {
        global $gantry;
        if ($this->get('enabled')) {
            $gantry->addScript('accordion.js');
            $gantry->addInlineScript($this->_accordion());
        }
    }
    function render($position="") {
    ob_start();
    ?>
        <div id="accordion">
            <dl>
            <?php foreach (glob("templates/rt_gantry_j15/features/accordion/*.php") as $filename) {include($filename);} ?>
            </dl>
        </div>
    <?php
    return ob_get_clean();
    }
    function _accordion() {
        global $gantry;
        $js = "
            jQuery.noConflict();
                (function($){   
                $(document).ready(function () {
                    $('#accordion').easyAccordion({ 
                        slideNum: true,                 
                        autoStart: true, 
                        slideInterval: 4000
                    });
                });
            })(jQuery);
        ";
        return $js;
    }
}

I want to call these three values in the templateDetails.XML file as a user input.

                    slideNum: true,                 
                    autoStart: true, 
                    slideInterval: 4000

Like this in the templateDetails.xml file:

<param name="accordion" type="chain" label="ACCORDION" description="ACCORDION_DESC">
    <param name="slideNum" type="text" default="true" label="Offset Y" class="text-short" />
    <param name="autoStart" type="text" default="true" label="Offset Y" class="text-short" />
    <param name="autoStart" type="text" default="4000" label="Offset Y" class="text-short" />
</param>

How can I do so? What will be the exact syntax for the same.

I am very new to programming ans specially to JavaScript.

Kindly help.

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery