【问题标题】:How to include javascript in Joomla virtuemart product details如何在 Joomla 德德玛特产品详细信息中包含 javascript
【发布时间】:2011-10-29 15:24:52
【问题描述】:

我实际上是在 http://virtuemart.net/documentation/Developer_Manual/Modifying_the_Layout.html 这个页面的帮助下自定义产品详细信息页面。我需要包含一些外部和内部 JavaScript。但不知道要添加脚本。请有人帮我这样做。

修改产品详情页面。我刚刚在以下文件中工作 components/com_virtuemart/themes/default/templates/product_details/flypage.tbl.php

VirtueMart 版本是 VirtueMart 1.1.9 稳定版

Joomla 版本是 Joomla! 1.5.15 稳定

提前致谢。

【问题讨论】:

  • 您好 Gowri,您是要 HTML,还是要使用 Joomla 框架将其添加到页面头部?
  • @udjamaflip:我不确定是否要添加。因为美德玛特是一个模块。所以它不会依赖于 joomla 模板。
  • Virtuemart 是一个组件,是的,但您仍会使用 Joomla 框架将项目添加到标题中。但是,问题仍然存在,您是希望 HTML 将 javascript 嵌入您的模板中,还是希望 PHP 在您的 中放置一个 JS 链接?
  • @udjamaflip:好吧,这是有道理的。如何在头部添加js。

标签: joomla joomla-extensions virtuemart joomla-template


【解决方案1】:

根据您在 cmets 中的回答,答案如下:

//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);

如果您想添加或自定义类似 IE 条件标签的内容,请参阅此处了解更多信息:http://docs.joomla.org/Adding_JavaScript_and_CSS_to_the_page 了解如何使用此对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 2012-12-05
    • 2014-03-07
    • 1970-01-01
    • 2014-02-22
    • 1970-01-01
    相关资源
    最近更新 更多