【问题标题】:How can I show template variables from articles with getResources?如何使用 getResources 显示文章中的模板变量?
【发布时间】:2016-03-18 08:56:47
【问题描述】:

我想使用“getResources”在我的主页上显示“文章”额外的文章。

这是我主页的代码:

[[getResources? &parents=`52` &tpl=`sample.ArticlesLatestPostTpl` &showHidden=`1` &includeContent=`1`   &includeTVs=`1` &processTVs=`1`  ]]

这是我的sample.ArticlesLatestPostTpl:

<li>
[[*myimage]]
  <a href="[[~[[+id]]]]">[[+pagetitle]]</a>
  [[+publishedon:notempty=`<br /> - [[+publishedon:strtotime:date=`%b %d, %Y`]]`]]
</li>

我的模板变量是[[*myimage]]

但是我看不到文章的模板变量。相反,我看到了主页的模板变量。

有人可以帮帮我吗?

【问题讨论】:

    标签: modx modx-revolution modx-getresources


    【解决方案1】:

    它是这样工作的:

    • [[*image]] 将显示当前字段“image”中的数据 文件。
    • [[+image]] 将显示所有字段“image”内的数据 您可能从当前文档中查询的​​资源。
    • [[+tv.image]] 可能 如果您使用使用“tv”的“getResources”,也可以工作。作为模板 默认为变量前缀。

    如果您有疑问,最好的信息是这两页:

    一般标签语法: https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/tag-syntax

    和不时使用的默认标签: https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/commonly-used-template-tags

    【讨论】:

      【解决方案2】:

      我找到了答案。

      我需要写[[+myimage]],而不是[[*myimage]]

      并且工作! :)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-04-25
        • 2019-08-06
        • 2023-01-29
        • 1970-01-01
        • 1970-01-01
        • 2019-12-11
        相关资源
        最近更新 更多