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;
}
}
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
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.
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;
}
}
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;
}
}