要加载的脚本列表存储在哪里?

Where is the list of scripts to be loaded stored?

在一个模板中,有些部分调用 Joomla 函数来加载多个 javascript 个文件,有些部分调用 css 个文件。 js 文件没有硬编码在模板文件中,AFAIK。 Joomla 在哪里存储 Javascript 个文件的路径列表?


编辑


我正在寻找模板中这样使用的列表的来源:

$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;

$load_favthb = true;
$lscripts = $doc->_scripts;

foreach ($lscripts as $k => $v) {
  if (strpos($k, 'favth-bootstrap') !== false) { $load_favthb = false; break; }
}

$doc->_scripts 的源存储在哪里?

如果您指的是您的模板加载的 javascript 文件(而不是您网站上的扩展名),那么这些文件的路径通常在您的模板文件之一中。

构建 Joomla 模板的方法有很多种,因此这些路径不会在每个模板的相同位置指定。但您总是会从 /templates/template-in-question/index.php

的顶部附近开始查看

例如,您的 Joomla 3 站点上可能安装了 Beez3 模板。

首先打开 /templates/beez3/index.php,如果您从顶部向下看,您会发现 Javascript 文件已加载到第 80-83 行

不是在 index.php 中加载 javascript 文件,一些模板将它们包含在辅助文件中(通常命名为 'params' 或 'head' 或 'includes')插入 index.php.

无论哪种方式,从模板的 index.php 文件的顶部向下扫描开始

编辑

Where is the source for $doc->_scripts stored?

Google <jdoc: include type=”head” /> 如果你想知道所有细节,但大多数来自 site-root/media/jui/site-root/media/system/

如果您要直接编辑其中一个文件,您的编辑可能会被 Joomla 更新覆盖。

更安全的方法是删除不需要的 js 脚本,然后添加替换。

// remove unwanted script . Path is relative to site root
unset($doc->_scripts[$this->baseurl.'/path/to/unwanted-script']);  
  
// add your replacement script. Path is relative to template root
$doc->addScript($tpath.'/js/new-script');