Petr
Petr

Reputation: 460

Check if we in backend area of October CMS

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?

Upvotes: 1

Views: 594

Answers (1)

Zakir hussain
Zakir hussain

Reputation: 631

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

Upvotes: 3

Related Questions