Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

RenderWith and $Layout override problem


Go to End


3 Posts   3243 Views

Avatar
guillaume

Community Member, 7 Posts

9 December 2009 at 7:50am

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.

Avatar
tobych

Community Member, 97 Posts

21 December 2009 at 7:49am

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

Avatar
guillaume

Community Member, 7 Posts

27 January 2010 at 11:13am

Edited: 27/01/2010 11:14am

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

Thanks,
Best Guillaume.