Jump to:

23493 Posts in 19008 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Test if a page is being accessed from the administrative area

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

Page: 1
Go to End
Author Topic: 520 Views
  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Test if a page is being accessed from the administrative area Link to this post

    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;
          }
    }

  • DeklinKelly
    Avatar
    Community Member
    197 Posts

    Re: Test if a page is being accessed from the administrative area Link to this post

    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;
          }
    }

    520 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.