Search code examples
joomlajoomla-extensionsvirtuemartjoomla-template

How to include javascript in Joomla virtuemart product details


I am actually customizing product details page with the help of http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html this page. I need to include some external and internal JavaScript.But don't know were to add script.Please some one help me to do this.

To modify product details page . i just worked in following file components/com_virtuemart/themes/default/templates/product_details/flypage.tbl.php.

Virtuemart version is VirtueMart 1.1.9 stable

Joomla Version is Joomla! 1.5.15 Stable

Thanks In advance.


Solution

  • Based on your responses in the comments here is the answer:

    //This line defines what JavaScript file you wish to add, change it as needed.
    $myJsFile = JURI::Base() . 'templates/my_template_name/js/myJsFile.js';
    
    //this line fetchs the jdocument object which is needed to add items to the head (amongst other things)
    $document =& JFactory::getDocument(); //Drop the & if PHP5
    
    //This line adds the previously setup JS url
    $document->addScript($myJsFile);
    

    If you want to add or something custom like IE conditional tags then see here for more info: http://docs.joomla.org/Adding_JavaScript_and_CSS_to_the_page on how to use this object.