如何获得 Silverstripe 4 中可能的候选模板列表?
How to get a list of possible template candidates in Silverstripe 4?
开发 SilverStripe 4 项目我发现获取给定覆盖的所有可能候选者的列表有点复杂。
所以我的问题是:
如何获得给定页面的可能候选模板的完整列表?
在控制器中时,您可以在控制器本身或 DataRecord
上调用方法 getViewerTemplates
,因为 getViewerTemplates
是 ViewableData
.[=18 上的方法=]
$this->dataRecord->getViewerTemplates();
$this->dataRecord->getViewerTemplates($action); //If you're calling an action
$this->getViewerTemplates(); //If you don't have a datarecord
实际上是 SSViewer
上 get_templates_by_class
方法的实现。
我想它会 return 你需要的。
开发 SilverStripe 4 项目我发现获取给定覆盖的所有可能候选者的列表有点复杂。
所以我的问题是:
如何获得给定页面的可能候选模板的完整列表?
在控制器中时,您可以在控制器本身或 DataRecord
上调用方法 getViewerTemplates
,因为 getViewerTemplates
是 ViewableData
.[=18 上的方法=]
$this->dataRecord->getViewerTemplates();
$this->dataRecord->getViewerTemplates($action); //If you're calling an action
$this->getViewerTemplates(); //If you don't have a datarecord
实际上是 SSViewer
上 get_templates_by_class
方法的实现。
我想它会 return 你需要的。