silverstripe短代码返回动态模板

时间:2013-05-07 16:28:50

标签: content-management-system silverstripe

我遵循这条指令,可以在页面的内容字段(HTMLEditor)中包含一个变量 - 这样该变量就可以替换为其他内容: http://www.balbuss.com/mini-introduction-to-shortcodes/

我想在$ Content中显示一个dataobjects列表。

遗憾的是,指令中的DummyHandler是静态的。所以我无法访问其中的Controller,让他做一些事情(生成列表。)

是否存在在静态函数中访问控制器的解决方案,或者是否有另一种更好的方法将变量放入$ Content。

THX, 弗洛里安

1 个答案:

答案 0 :(得分:1)

Controller :: curr()可能就是你追求的目标? 与Controller :: hasCurr()一起使用,因为在使用Controller :: curr()时没有控制器会出现错误

请参阅https://github.com/silverstripe/sapphire/blob/3.0/control/Controller.php#L384