从MODX中的输出修饰符调用模板变量



我正在尝试在modx中的if语句中输出一个模板变量,但它没有输出。

我有多个页面,其中有指向文章的链接,关键是仅在首页上输出模板变量内容,而不是其他内容。

// This gives no output:
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]
// This outputs "yes" on the first page and "no" on others:
[[!#get.page:is=`1`:or:is=``:then=`yes`:else=`no`]]

我什至尝试过,但是它仍然没有给出任何输出。我想问题与输出修饰符无关:

[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=`[[*content]]`]

我正在使用Modx Revo 2.7.0

任何帮助将不胜感激,谢谢!

实际上在您的情况下缺少双重闭合角括号"]

[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]]

`or:is=`与空状态匹配。除非有意,否则您应该能够将其删除。另外,`:else=``是默认状态,因此,您也不需要。

以下内容应起作用,您将拥有更干净的代码:

[[!#get.page:is=`1`:then=`[[*content]]`]]

最新更新