質問

Since upgrading from Silverstripe 3.0 to 3.1, rendering a DataObject with a template does no longer work.

I extended a ModelAdmin to display some rather complex markup (some data table) inside its edit form.

SSViewer::set_theme('mytheme');
Requirements::clear();
$form->Fields()->insertAfter(
    new HtmlEditorField_Readonly(
        'Title', 
        '', 
        //render DataObject with template inside the form
        $analytics->renderWith('MyTpl')
    ), 
    'SomeField'
);
Requirements::restore();

That worked beautifully before the upgrade and now fails with:

[User Warning] None of these templates can be found in theme 'mytheme': MyTpl.ss

(Template file does exist though)

Is there anything wrong with rendering a DataObject with a templates in this context?
Any ideas on why that wouldn't work or how to fix it?

役に立ちましたか?

解決

As mentioned above you could (or should, some could argue) place your templates under mysite/templates/... (especially if they are for the cms) if you have themes enabled (am pretty sure) SS looks into that theme folder first for templates which can sometime be annoying and create caching issues...

I personally don't use themes anymore, I just have everything under mysite which I actually call something relevant to my project, keeps things tidy and easy to publish.

Note: themes are still useful, but maybe more for site that would change design, like e-commerce site with a xmass theme for example. I think there was a discussion about this on SilverScoop...

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top