是否在Silverstripe 3中有一个现成的功能,让所有模板都存在于一个特定的文件夹中,以便将它们放在Arraylist中?
如果没有,之前有人这样做过吗?
我的目标是从下拉列表或单选按钮集中选择模板。
或者我应该用...
$files = glob("/path/to/directory/*.ss");
谢谢。 SEPP。
userforms模块does this显示可能的收件人电子邮件模板列表。这是相关部分:
$templates = [];
$finder = new SS_FileFinder();
$finder->setOption('name_regex', '/^.*\.ss$/');
$found = $finder->find(BASE_PATH . '/path/to/directory');
foreach ($found as $key => $value) {
$template = pathinfo($value);
$templates[$template['filename']] = $template['filename'];
}