Jump to:

23355 Posts in 17702 Topics by 2862 members

General Questions

SilverStripe Forums » General Questions » RenderWith and $Layout override problem

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: 2458 Views
  • guillaume
    Avatar
    Community Member
    7 Posts

    RenderWith and $Layout override problem Link to this post

    Hi there,
    I just discovered a weird behaviour or i might do something wrong.

    i have in my template a variable $MemberStatus. Then to that i have the function MemberStatus in my page controller.
    the function look like this:

    function MemberStatus() {
    return $this->renderWith('MemberStatus');
    }

    So my template $MemberStatus return the right content but $Layout return aswell MemberStatus.ss content. To fix it i need to add a parameter to the renderWith function as follow:

    function MemberStatus() {
    return $this->renderWith('MemberStatus', array('fixingparam'=>'value'));
    }

    Any Ideas ?
    Br, G.

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: RenderWith and $Layout override problem Link to this post

    I'm confused. What are you trying to do here? I imagine you're trying to show a member's status in some fancy way using a template. If so you should just be able to have a template templates/Includes/MemberStatus.ss, which uses a placeholder called $MemberStatus or whatever's needed. In your layout template, or a subsequently included template, just use <% include MemberStatus %> to pull in the MemberStatus.ss template.

    Toby

  • guillaume
    Avatar
    Community Member
    7 Posts

    Re: RenderWith and $Layout override problem Link to this post

    Yes defenitly too fancy... Using include will do it perfectly.
    The behaviour is not weird at all

    Thanks,
    Best Guillaume.

    2458 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.