1

I think this question has been asked many times, but I am sorry not to find a working solution. May be I am doing something wrong. I want to display a specific node form in my default custom theme and not in the admin theme when the administrator logs in. However, other node forms should continue to display in the admin theme. Hence the "Use the administration theme when editing or creating content " should be checked.

I have tried the themekey module. I came across that there's something called themekey compatibility by which this can be achieved. But I fail to find an example.

I want the default theme for a specific content type. Also I tried the followings: hook_custom_theme & hook_theme_init as described in How to change the theme for a particular admin page in drupal?

Thanks

closed as unclear what you're asking by Mołot, Letharion, Krishna Mohan, Yusef Mohamadi, Adam Balsam Dec 22 '14 at 22:30

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • "specific node form" - form for specific node ID? for specific content type? Or what exactly is specified in your case? – Mołot Sep 30 '14 at 10:39
  • Oh, and for "I also tried using some hooks from my custom modules but without success." - See our help center. If you want help with code you wrote, please post that code, and describe how it failed. – Mołot Sep 30 '14 at 10:48
  • I want the default theme for a specific content type. Also i tried the followings: hook_custom_theme & hook_theme_init as described in drupal.stackexchange.com/questions/97364/… Hope this clears up a little. – Pratip Ghosh Sep 30 '14 at 12:03
  • This site is not a forum - edit new data into question. Don't use comments to create discussion threads. – Mołot Sep 30 '14 at 12:07
2

There is a hook that you can use to set which pages use the admin theme and which don't.

The hook is hook_admin_paths().

The node module uses this hook to provide the functionaity where you can set node forms to use the admin theme (see node_admin_paths()).

If you wanted to set certain paths to use the admin them (or not use it) you could implement that hook, however if you want to change admin paths that another module has already defined you need to use hook_admin_paths_alter().

In this case the node module defines a wild card path for all node add pages like this 'node/add/*' => TRUE

Since you only care about a specific node type you can ignore that and do this:

/**
 * Implements hook_admin_paths().
 */
function MODULENAME_admin_paths() {
  // We have configured the site to use the admin theme for node forms
  // however we want the article content type to use the default theme
  // instead of the admin theme.
  $paths = array(
    'node/add/article' => FALSE,
  );
  return $paths;
}

As you can see in path_is_admin(), where the check is done to see if the current page is an admin page, for a page to be an admin page it must have a matching path that is TRUE and also not have one that is FALSE. So by adding this FALSE in for this specific page you are overriding the wildcard node/add/* from the node module.

The problem that you then have is the node edit page (if you also want that to use the same theme as the node add form), because the URL for the node edit page has nothing in it that relates to the content type so you can't override node edit pages based on their type.

You could get the node IDs of all nodes of your specific type and add each individual node edit path however if you have a large number of nodes that is not going to be ideal.

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