weixin_39525933
weixin_39525933
2020-12-27 11:43

renderWith($ArrayOfTemplates) is using the template with the shortest file name instead of following the order of the array ..

renderWith($ArrayOfTemplates) is using the template with the shortest file name instead of following the order of the array when template files are not in the default folders (Not in Layout or Includes) Example: themes/MyTheme/templates/Section/ has a.ss HeaderSection.ss & HeaderSection2.ss , a.ss will always be used 1st if all 3 items are passed in to renderWith().

该提问来源于开源项目:silverstripe/silverstripe-framework

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

5条回答

  • weixin_39918682 weixin_39918682 4月前

    Could you please paste the actual renderWith calls you're using?

    点赞 评论 复制链接分享
  • weixin_39525933 weixin_39525933 4月前
    
    public function Render_Title($Template = null) {
    
        $renderWith = array();
        if ($Template) {
            $renderWith[] = $Template;
        }
        $renderWith[] = $this->ClassName . "_Title";
        $renderWith[] = "Gadget_Title";
        $renderWith[] = 'Title';
    
        return $this->renderWith($renderWith);
    
    }
    

    'Title.ss" will always be used 1st. if I comment out "Title" the next shortest template name is used (Gadget_Title). Changing the order of the array has no effect .

    点赞 评论 复制链接分享
  • weixin_39918682 weixin_39918682 4月前

    Looking at TemplateManifest->getCandidateTemplate(), I can't see how this would be related to the length of a template name... The code example doesn't match the template names you described in the ticket. Can you please add a folder listing of all custom templates in your codebase? (so mysite/ and themes/)

    点赞 评论 复制链接分享
  • weixin_39525933 weixin_39525933 4月前

    I took a screenshot of my file structure : http://tinypic.com/view.php?pic=2zzjjh5&s=5 (Templates) http://tinypic.com/r/9roosh/5 (Php Code)

    I use a "_" underscore in my file/folder names, could SS be treating them as sub_themes & getting the priority of templates wrong ?

    点赞 评论 复制链接分享
  • weixin_39918682 weixin_39918682 4月前

    You're nesting templates into two levels of subfolders, correct?

    
    templates/
      Gadgets/
        Gadgets_Page/
          MyTemplate.ss
    

    I'm not sure that's supported. We should either document that it isn't, or fix it. Somebody keen to write a test in TemplateManifestTest?

    点赞 评论 复制链接分享

相关推荐