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

If Menu(2) Doesn't Exist do This...


Go to End


3 Posts   2086 Views

Avatar
AlastairW

Community Member, 5 Posts

15 April 2010 at 9:17am

Hi,

I'm trying to load a stylesheet if Menu(2) doesn't exist:

<% if (!isset(Menu(2))) %>
   <!--[if IE 7]>
      <link rel="stylesheet" type="text/css" href="/themes/pmb/css/ie7-menu-2-fix.css" />
   <![endif]-->
<% end_if %>

However that code obviously isn't right and I can't figure it out. I'm sure its extremely easy but anyone have a tip? My Googling has failed.

Thanks

Avatar
Willr

Forum Moderator, 5523 Posts

15 April 2010 at 4:43pm

Edited: 15/04/2010 4:44pm

In SS templates you can simply do the following. isset() is a PHP function

<% if Menu(2) %>
...
<% else %>
...

Avatar
AlastairW

Community Member, 5 Posts

16 April 2010 at 9:15am

Ahh it was super easy. Cheers Will, that completes the website!