【问题标题】:How to add and use jquery and css file in joomla module..?如何在 joomla 模块中添加和使用 jquery 和 css 文件..?
【发布时间】:2011-01-22 09:11:23
【问题描述】:
$document = &JFactory::getDocument();//getting document ref object
$document->addScript(JURI::root() . 'modules/mod_my_slider/jquery.js');

$path = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."modules/mod_my_slider/images";
$path = str_replace("index.php","",$path);
?>
<script language="javascript">
  jQuery('#block').show();
 </script>
 <center>
 <div height:220px; width:500px; border:1px solid black;>
  <img class="slide" height="220px" width="500px" src="<?php echo $path; ?>/pier1.jpg"/>
 </div>
 <div id="block" style="height:100px; width:10px; display:none; background-color:white;">BETA</div>
 </center>
?>

我像上面一样尝试,我还包含 jquery 文件,但该行不显示。

【问题讨论】:

    标签: jquery css module joomla1.5


    【解决方案1】:
    $document =& JFactory::getDocument();
    $document->addScript($url);
    $document->addStyleSheet($url);
    

    这绝对是向模块添加 jscript 和 CSS 的正确语法。我能看到的唯一问题是,如果您使用安装程序,Joomla 会自动将 JS 文件放在 modules/module_name/js 中,并将 CSS 放在 modules/module_name/css 文件夹中。如果该行根本不存在,那么您还有另一个问题,如果该行存在但未添加文件,您可能需要将代码更改为

    $document->addScript(JURI::root() . 'modules/mod_my_slider/js/jquery.js');
    

    【讨论】:

      猜你喜欢
      • 2011-12-21
      • 2012-11-27
      • 1970-01-01
      • 2014-01-20
      • 1970-01-01
      • 2014-05-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多