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.

Template Questions /

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

a "require" block in a "if/end_if" block : is it possible


Go to End


4 Posts   1729 Views

Avatar
Myrdhin

Community Member, 70 Posts

17 March 2010 at 5:26am

Edited: 24/04/2010 12:34am

Hello,

I try do to that :

<% if ClassName != HomePage %>
	<% require themedCSS(pageLayout) %>
	<% require themedCSS(pageTypography) %>
<% end_if %>

But it doesn't work : the pageLayout and pageTypography CSS files are read when i call a HomePage type. I know it's possible to do in the init() function in the controller classes (other than HomePage_controller) but i would like to do in the template.

Is it possible ? Perhaps i do a mistake ?
thanks for your help.

Avatar
dhensby

Community Member, 253 Posts

17 March 2010 at 12:50pm

I'm not sure if you can even put <% requirements .. %> in if blocks (although i see no reason why not). However, i have never known != to work in the templating language (despite what the recipes / docs / tutorials say) so you have to go:

<% if ClassName = HomePage %><% else %>
....
<% end_if %>

Avatar
Hamish

Community Member, 712 Posts

17 March 2010 at 6:21pm

You can put Requirements calls anywhere but they won't respect <% if %> blocks.

Avatar
Myrdhin

Community Member, 70 Posts

20 March 2010 at 6:22am

Thanks :)