silverstripe Sitetree onAfterWrite - renderWith Error: Template not found

元气小坏坏 提交于 2019-12-24 02:59:10

问题


for the automated generation of pdfs from the page content I want to use the renderWith function within onAfterWrite in the Page Class (later with DOMPDF the PDF will be generated from the returned HTML):

public function onAfterWrite() {
    parent::onAfterWrite();
    $this->renderPdf();
}
public function renderPdf() {
    return $this->renderWith(array('Pdf'));
}

There is always this Error returned when saving the Page: None of these templates can be found in theme 'mytheme': Pdf.ss

The Template exists for sure and calling the Function renderPdf via a Template works perfectly. This is a bit weird. (ss 3.1.1)

many thanks, florian

EDIT: maybe it is related to 3.1, I just tested in 3.0.5. without any issues. In a clean 3.1.2 install I was able to reproduce the error.


回答1:


Where is your template located exactly? Have you tried to put it under the 'templates' folder, and not under 'Layout' or 'Includes'? In your case, I would try to move that file here: /themes/mytheme/templates/Pdf.ss As you are calling for a standalone template (so not alongside 'Page' for example), the .ss file should be accessible as a 'root' template, as opposed to a layout template.



来源:https://stackoverflow.com/questions/20224415/silverstripe-sitetree-onafterwrite-renderwith-error-template-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!