【问题标题】:Show only “Read more” link in drupal 8在 drupal 8 中仅显示“阅读更多”链接
【发布时间】:2016-06-11 09:31:33
【问题描述】:

如何仅显示 阅读更多 链接,并在节点预告片末尾删除或取消设置其他链接,例如“添加新 cmets”或“2 条评论”?

【问题讨论】:

  • 你有没有试过先为自己做点什么?
  • 是的,我正在尝试为自己做一些事情。
  • 那么,请用您目前所做的更新您的帖子。
  • 我在这里找到了一个解决方案:link 但不能正常工作。

标签: drupal themes customization drupal-8 teaser


【解决方案1】:

为了拥有自定义链接,您需要 links--node.html.twig 模板文件,它会覆盖主题以显示节点链接。

1. 粘贴这个:

This is links.html.twig talking.... 
{% if links -%}
  {%- if heading -%}
    {%- if heading.level -%}
      <{{ heading.level }}{{ heading.attributes }}>{{ heading.text }}</{{ heading.level }}>
    {%- else -%}
      <h2{{ heading.attributes }}>{{ heading.text }}</h2>
    {%- endif -%}
  {%- endif -%}
  <ul{{ attributes }}>
    {%- for key, item in links -%}
      <li{{ item.attributes.addClass(key|clean_class) }}>
        {%- if item.link -%}
          {{ item.link }}
        {%- elseif item.text_attributes -%}
          <span{{ item.text_attributes }}>{{ item.text }}</span>
        {%- else -%}
          {{ item.text }}
        {%- endif -%}
      </li>
    {%- endfor -%}
  </ul>
{%- endif %}

进入你的编辑器

2.随意定制。

3.另存为themes/YOUR_THEME/templates/links.html.twig

4.清除缓存

5. 亲身体验

感谢您的反馈。

【讨论】:

  • 我在我的主题文件夹中的模板目录中有这样的文件作为默认文件,但我不知道如何自定义它,你能帮助我达到我的目标,提供更多关于这个问题的信息.
  • 因为这将是您的下一步,我建议您发布一个新问题,提供您期望链接--node.html.twig 应该产生的内容。同时,感谢您对我的回复的反馈。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-02-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-01
相关资源
最近更新 更多