Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Custom Controller limitations compared to ContentController?

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

Page: 1
Go to End
Author Topic: 1693 Views
  • zatic
    Community Member
    3 Posts

    Custom Controller limitations compared to ContentController? Link to this post

    Hi Community,

    I have a few questions about custom controllers:

    From the documentation I read here

    I figured I should use a customer controller for my data instead of content controllers as my model is not content / page oriented.

    So I created a first prototype using a custom controller as shown here:

    and rendered it with $this->renderWith('MyTemplate') which all works fine so far.

    However, I am missing some important functionality compared to using ContentController and SiteTree. Specifically:

    - Can I use the template Hierarchy? renderWith() only seems to find templates in the root themes directory, but doesn't seem to be able to compose themes from templates and layouts. Is this strictly connected with the SiteTree model or can I enable the template/layout composing with custom controllers and renderWith as well?

    - From the template, I can not access objects as I used to with ContentController, where I simply had a method MyObject() that would get called when I access $MyObject in the template. Again, is this functionality not possible with custom controllers, or what can I do to use this? Or, generally, how can I access my model from the template using my custom controller? I tried to use $this->customize() which appeared to be the answer, however this is also a ContentController method if I am not mistaken.

  • KINKCreative
    Community Member
    56 Posts

    Re: Custom Controller limitations compared to ContentController? Link to this post

    Has there ever been a solution to this? It seems that class methods are not executed from <% control %> loops and this is exactly the issue. It has come so far actually that even forTemplate() is proclaimed on the controller, preventing custom Class templates...

    Any help/insight on this would be greatly appreciated!

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.