小编Kat*_*ndl的帖子

Silverstripe - 是否可以在include语句中使用变量?

我正在使用silverstripe模板,我想循环遍历当前页面的子页面,并根据该子页面的类型动态输入"include"控件中的模板名称.

这是我到目前为止的代码:

    <div id="tertiary-content">                   
        <% if $Children %>
            <% loop $Children %>
                <% include $ClassName %>
            <% end_loop %>
        <% end_if %>
    </div>
Run Code Online (Sandbox Code Playgroud)

(我的模板中有ss文件/包含与$ ClassName变量相关的目录)

这是我得到的错误:

错误是:遇到未知的打开块"循环".也许你错过了结束标签或错误拼写了?

我在silverstripe论坛上发现了这篇文章,这让我觉得它应该有用:http: //www.silverstripe.org/archive/show/1023

实际上是否可以在include控件中包含变量?

variables templates include silverstripe

3
推荐指数
2
解决办法
3804
查看次数

标签 统计

include ×1

silverstripe ×1

templates ×1

variables ×1