How can I found out programaticaly where am I in frontend or backand?
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.
- Page 11(current)
- 2
- Next 10 entries
hmmmm - how about if your url segment begins "admin"?
No.
I'm trying:
class StatisticsExtender extends DataObjectDecorator {
function contentControllerInit() {
$cur_url = explode("?",$_SERVER['REQUEST_URI']); // I expecting 'admin'
$params = Director::urlparams();
$controller = Director::urlParam('Controller');
$be = is_subclass_of($controller,"LeftAndMain");
$frontend = ((isset($params['Controller']) && $params['Controller'] == 'RootURLController') || !isset($params['URLSegment']) || (isset($params['URLSegment']) && $params['URLSegment'] != 'sapphire') ? 1 : 0);
$backend = ((isset($params['URLSegment']) && $params['URLSegment'] == 'sapphire') ? 1 : 0);
//...
}
//...
}
No success.
hmmm well I'd say it would be something in director... Director::get_current_page() and then get the URLsegment from there...
what is it that you are going to use this information for?
I'm trying to write statistic module with optional params: use for frontend || use for backend || use for all.
how about tracking when someone is logged in? non-logged in would mean frontend
any road - I would just track the pages and then worry about how to filter based on "this is an admin url" later. Also I'd ensure the tracking only occurs when (!Director::is_ajax())
User can be loged in frontend and backend, right?
You know, in my own CMS I wrote modules, I can read params from xml as it has e.g. Joomla!.
I want the same functionality in SS (e.g. in SS SiteConfig), and I want to know where user sit frontend/backend.
I don't want to use google or piwik (via javascript) nor call from template.
>> User can be loged in frontend and backend, right?
true, but I am implying that if they are not logged in and it is not ajax it will be a frontend page.
- Page 11(current)
- 2
- Next 10 entries