【问题标题】:Silverstripe 3 list all templates (.ss - files) in a specific folderSilverstripe 3 列出特定文件夹中的所有模板(.ss - 文件)
【发布时间】:2019-04-23 15:51:33
【问题描述】:

Silverstripe 3 中是否有现成的功能可以让所有模板位于特定文件夹中以将它们放在 Arraylist 中?

如果没有,以前有人做过吗?

我的目标是从下拉列表或单选按钮集中选择模板。

或者我应该用类似的东西来做......

$files = glob("/path/to/directory/*.ss");

谢谢。 sepp.

【问题讨论】:

    标签: php templates arraylist directory silverstripe


    【解决方案1】:

    用户表单模块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'];
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 2017-12-06
      • 1970-01-01
      相关资源
      最近更新 更多