【发布时间】:2011-05-10 23:51:40
【问题描述】:
我有一个前端组件视图,我需要在标题中包含一个 .js 文件(标题是由 Joomla 生成的,而不是在 default.php 中硬编码)。前端组件文件为mysite.com/components/com_arrcard/views/tmpl/default.php; javascript 文件位于 mysite.com/administrator/components/com_arrcard/js/CalendarPopup.js。
这是我在 default.php 中尝试过的:
$document =& JFactory::getDocument();
$popUrl = JURI::root(true).'/website/documents/ccv.html';
$popImage = JURI::root(true).'/website/documents/cv_card.jpg';
$popPhone = JURI::root(true).'/website/documents/phone.html';
$document->addScript( JURI::root(true).'/administrator/components/com_arrcard/js/CalendarPopup.js' );
$popImage 和 $popPhone 变量设置正确,但没有添加脚本 - 当我查看呈现的页面源时,CalendarPopup.js 不存在。
谁能帮帮我?我在这里做错了什么?我也试过了
$document->addScript('administrator/components/com_arrcard/js/CalendarPopup.js' );
这也不起作用。在管理员 com_arrcard 组件的视图中包含完全相同的文件时,addScript 代码确实有效。 addScript 的工作位置是否有一些限制?
【问题讨论】:
标签: joomla