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

Test if a page is being accessed from the administrative area


Go to End


2 Posts   798 Views

Avatar
DeklinKelly

Community Member, 197 Posts

10 August 2010 at 1:45am

How can I test if a page is being accessed from the administrative area?

   function canView() {
		if( IF_YOU_ARE_IN_THE_ADMINISTRATIVE_AREA  ) {
			return true;
		} else {
			return false;
		}
   }

Avatar
DeklinKelly

Community Member, 197 Posts

10 August 2010 at 12:37pm

Thanks to Martijn and simon_w for helping with this in the forums.

Controller::curr() can be used to test the object type.

And SSViewer::current_theme() can be used to for a theme.

For example,

   function canView() {
		if(SSViewer::current_theme()===null) {
			return true;
		}
		else {
			return false;
		}
    }