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

How detect dev/live mode in template?


Go to End


3 Posts   2823 Views

Avatar
vwd

Community Member, 166 Posts

23 January 2012 at 3:46pm

Hi,

Is there a way to detect dev mode or live mode from within the template?

I'm trying to disable Google Analytics (not include JS) when in dev mode. Am I correct in assuming that for this case, it is best (from MVC perspective) to do it at the controller level, not template? Eg.

Director::isDev();
Director::isTest();
Director::isLive();

Thanks.

VWD.

Avatar
swaiba

Forum Moderator, 1899 Posts

23 January 2012 at 10:27pm

You'll just need to wrap then in a function in the controller

Avatar
vwd

Community Member, 166 Posts

23 January 2012 at 11:13pm

Of course - how simple!

So there aren't any in-built template tags.

Thanks Swaiba.