在 drupal 8 中仅显示“阅读更多”link

Show only “Read more” link in drupal 8

我如何才能只显示 阅读更多内容 link,并删除或取消设置其他 link,例如 "add new comments" 或“2 条评论”在节点预告结束时?

为了拥有自定义链接,您需要 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. 实际操作

感谢您的反馈。