Ad

Check If We In Backend Area Of October CMS

- 1 answer

In some places of my code I need to check if it's a backend area or a public page. I wrote a simple function in my Utils class.

    static public function isInBackend()
    {
        return (strpos(Url::current(), Config::get('cms.backendUri', 'backend')) !== false);
    }

Does anyone know better ways to check that?

Ad

Answer

It's very easy in OctoberCMS to check whether you are in backend or not; just see below code for that:

if(\App::runningInBackend()) {
    //write your code here
}

You can learn more from this documentation link: https://octobercms.com/docs/services/application#application-helpers

Ad
source: stackoverflow.com
Ad