【发布时间】:2017-01-22 20:05:40
【问题描述】:
我是 Drupal 的新手,我非常喜欢它。我正在自学,但我现在遇到了一个问题。
我创建了一个显示标题和链接列表的自定义块。因此,该块中的唯一字段是链接类型。这是我的页脚区域的一个块。因此,当用户点击时,它会在新标签页中打开一个新网站。
我想改变这个块类型的 html 输出,所以我拿出了这个主题建议: field--block-content--field-links--footer-links.html.twig
我的问题是如何为每个<a>tag 添加一个类?
我尝试使用模块“链接类”。它工作马车。它只在安装模块之前读取 css 中已经存在的类。它不会读取安装模块后创建的新类。我尝试了不同的东西,多次清除缓存但很奇怪。必须有更好的方法来添加没有模块的类。
谁能帮助我并向我展示将类添加到我的<a> 标签的最佳方法?
谢谢你:)
这是默认模板
{% if label_hidden %}
{% if multiple %}
<div{{ attributes }}>
{% for item in items %}
<div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}
</div>
{% else %}
{% for item in items %}
{{ item.content }} -------------> add class here
{% endfor %}
{% endif %}
{% else %}
<div{{ attributes }}>
<div{{ title_attributes }}>{{ label }}</div>
{% if multiple %}
<div>
{% endif %}
{% for item in items %}
<div{{ item.attributes }}>{{ item.content }}</div>
{% endfor %}
{% if multiple %}
</div>
{% endif %}
</div>
{% endif %}
【问题讨论】:
标签: drupal-8