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.

General Questions /

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

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

Test if a page is being accessed from the administrative area


Reply


2 Posts   576 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;
      }
}