Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am writing a Single Page Frontend to a Drupal backend using AngularJS.

It is basically a module that bootstraps the Single Page Application.

HOWEVER, because the application takes control over the URL routing, I can no longer access the admin/.

Hence, ideally I would just like to bootstrap the App on the root url and not if the requested url is admin/ etc.

Can I set this up using a module hook or how can I achieve this?

EDIT

As Clive pointed out one can use !path_is_admin(current_path()).

Follow up: How can admin theme be loaded in the else clause?

if (!path_is_admin(current_path())) {

    return array(
      'html' => array(
        'render element' => 'page',
        'template' => 'htmlui',
      ),
    );
}

else{

    //LOAD ADMIN THEME HERE?

}
share|improve this question

1 Answer 1

You can use the path_is_admin() function, e.g.

if (!path_is_admin(current_path())) {
  // Do whatever you need to
}
share|improve this answer
    
Moved to question –  dani May 6 at 12:44
    
Sorry you've lost me - so you want to switch themes based on the admin URL? It would be very useful to edit your question and describe exactly what you're trying to do; at the moment there's no mention of themes in your question –  Clive May 6 at 12:47
    
Thanks Clive, I updated the question! –  dani May 6 at 12:49
    
You can't change the theme from a page callback (well, you probably can but there aren't API methods so I wouldn't call it a 'supported operation' as such). That sort of decision happens in hook_custom_theme() usually –  Clive May 6 at 12:51
    
Once logged in to the admin page, it looks good. But the log in screens at /admin and /user have no CSS styling when logged out? That is what I am getting at ... –  dani May 6 at 12:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.