Grav - 在树枝中使用简码
Grav - Using shortcodes in twig
关注 , I have found that there is a plugin named shortcodes 这可能对您有所帮助。
我已经安装了插件并创建了一个新页面:
---
title: slide1
media_order: slider1.jpeg
taxonomy:
category:
- 'Home Slider'
process:
markdown: true
twig: true
routable: false
cache_enable: false
visible: false
---
[section name="slide_title"]
Precisión y Calidad
[/section]
[section name="slide_subtitle"]
La máxima calidad y seguridad para nuestros clientes
[/section]
[section name="slide_link"]
www.google.es
[/section]
然后我有一个被调用的部分,它使得:
{% for slide in taxonomy.findTaxonomy({'category': 'Home Slider'}) %}
<span>TEST</span>
<span>{{ slide.title }}</span>
<span>{{ slide.shortcode.section.slide_title }}</span>
<span>{{ slide.shortcode.section.slide_subtitle }}</span>
<span>{{ slide.shortcode.section.slide_link }}</span>
{% endfor %}
但这只会生成:
TEST
slide1
并且它不输出短代码部分内容。
当您不直接处理 page
变量时,您链接到的文档显示了正确的语法:
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_title }}
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_subtitle }}
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_link }}
关注
我已经安装了插件并创建了一个新页面:
---
title: slide1
media_order: slider1.jpeg
taxonomy:
category:
- 'Home Slider'
process:
markdown: true
twig: true
routable: false
cache_enable: false
visible: false
---
[section name="slide_title"]
Precisión y Calidad
[/section]
[section name="slide_subtitle"]
La máxima calidad y seguridad para nuestros clientes
[/section]
[section name="slide_link"]
www.google.es
[/section]
然后我有一个被调用的部分,它使得:
{% for slide in taxonomy.findTaxonomy({'category': 'Home Slider'}) %}
<span>TEST</span>
<span>{{ slide.title }}</span>
<span>{{ slide.shortcode.section.slide_title }}</span>
<span>{{ slide.shortcode.section.slide_subtitle }}</span>
<span>{{ slide.shortcode.section.slide_link }}</span>
{% endfor %}
但这只会生成:
TEST
slide1
并且它不输出短代码部分内容。
当您不直接处理 page
变量时,您链接到的文档显示了正确的语法:
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_title }}
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_subtitle }}
{{ slide.contentMeta.shortcodeMeta.shortcode.section.slide_link }}