Jump to:

23487 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Template not found

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 721 Views
  • k0m0r
    Avatar
    Community Member
    39 Posts

    Template not found Link to this post

    Hi.
    I just encountered a strange behaviour of template renderer.
    My Page_Controller looks as follows:

    class Page_Controller extends ContentController {
    function xml() {
    $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"');
    return array();
    }
    }

    And then I have several page types extending both Page and Page_Controller, so I can use different templates. But for a strange reason one of my subclasses does not find an existing template.
    I have templates/Page_xml.ss template that looks like these:

    <page id="$ID">
    $Layout
    </page>

    And in templates/Layout folder, for example:

    ExamplePage.ss
    ExamplePage_xml.ss
    TestPage.ss
    TestPage_xml.ss

    When calling example-page/xml, it renders correctly using Page_xml.ss and Layout/ExamplePage_xml.ss
    But for a strange reason one of my subclasses, let's say TestPage, cannot find an existing TestPage_xml.ss template, so it renders using Page_xml.ss and then TestPage.ss (not TestPage_xml.ss).
    Every other class in the project works perfectly.

    I triple checked everything for typos and anything. Does anyone encountered this problem?
    I tried deleting the pages, the classes, rebuilding the database, flushing templates - no can do, my existing TestPage_xml template is simply ignored.
    What could I miss?

    721 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.