Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Colorbox JS和CSS未添加到所有页面中_Php_Drupal 8_Colorbox_Drupal Theming_Drupal Templates - Fatal编程技术网

Php Colorbox JS和CSS未添加到所有页面中

Php Colorbox JS和CSS未添加到所有页面中,php,drupal-8,colorbox,drupal-theming,drupal-templates,Php,Drupal 8,Colorbox,Drupal Theming,Drupal Templates,我在基于Drupal8的站点上设置了一个Colorbox模块,我发现它不适用于每种内容类型,因为与Colorbox相关的CSS和JS文件并没有包含在所有页面中 我有两种不同的内容类型,让我们称之为好的和坏的。两者都在标准html.html.twig模板中呈现CSS和JS,并使用该 它们之间唯一的区别是,在好的内容类型中,有一个公共图像字段,我在其中设置了一个Colorbox作为视图“处理程序”,而在坏的模板中,图像是在其代码中创建的。因此,我在等效元素中添加了一个CSS类( Colorbox以及

我在基于Drupal8的站点上设置了一个Colorbox模块,我发现它不适用于每种内容类型,因为与Colorbox相关的CSS和JS文件并没有包含在所有页面中

我有两种不同的内容类型,让我们称之为好的和坏的。两者都在标准html.html.twig模板中呈现CSS和JS,并使用该

它们之间唯一的区别是,在好的内容类型中,有一个公共图像字段,我在其中设置了一个Colorbox作为视图“处理程序”,而在坏的模板中,图像是在其代码中创建的。因此,我在等效元素中添加了一个CSS类(


Colorbox以及所有模块和库仅在必要时加载(因为它是一个字段格式设置程序,只有以该格式显示该字段时才会加载)。这是仅向浏览器发送必要代码的默认行为。
您可以在模块的每个页面中加载Colorbox。

谢谢,我会尝试。好的,我已经安装了这个模块,但问题仍然存在。因此我可以向元素添加必需的属性,但在放置元素的页面上,没有加载Colorbox所需的CSS和JS。我已经验证了templatest,它应该是其中的一部分模板/html.html.twig,但正如我在描述中所写,它不在我想要的页面上:(我在simplytest.me上试用过,效果不错。我在想有什么不同。你是否将jquery.colorbox-min.js添加到了库中?生成的HTML中是否有所有js文件?
这就是问题所在-我在页面中没有与colorbox相关的js(和CSS)文件,我不知道为什么:(我在Drupal论坛的帖子中更好地描述了我的问题:如果有帮助的话。
<!-- BEGIN OUTPUT from 'themes/cav/templates/html.html.twig' -->


<!DOCTYPE html>
<html lang="cs" dir="ltr" prefix="og: http://ogp.me/ns#">
  <head>
...
<link rel="stylesheet" media="all" href="/core/modules/quickedit/css/quickedit.icons.theme.css?q01vyb" />
<link rel="stylesheet" media="all" href="/core/themes/seven/css/components/quickedit.css?q01vyb" />
<link rel="stylesheet" media="all" href="/modules/colorbox/styles/plain/colorbox_style.css?q01vyb" />
<link rel="stylesheet" media="all" href="/core/modules/toolbar/css/toolbar.theme.css?q01vyb" />
...

<!-- BEGIN OUTPUT from 'themes/cav/templates/html.html.twig' -->


<!DOCTYPE html>
<html lang="cs" dir="ltr" prefix="og: http://ogp.me/ns#">
  <head>
    <meta charset="utf-8" />
...
<link rel="stylesheet" media="all" href="/core/modules/quickedit/css/quickedit.icons.theme.css?q01ykj" />
<link rel="stylesheet" media="all" href="/core/themes/seven/css/components/quickedit.css?q01ykj" />
<link rel="stylesheet" media="all" href="/core/modules/toolbar/css/toolbar.theme.css?q01ykj" />
...