Hi everyone,
I'm using the drupal Admin theme with the Rubik theme. And Garland for my front end (this will soon be changed when I start building the front end). My problem, is that I wish to create seperate pages for showing a list of editable nodes. Instead of using /node/edit - I am going to use Views to create a seperate list for pages, one for stories and so on. However, if I create a page, it's obviously going to use my front end theme.
Is there a way of choosing the Admin theme for a newly created page? Or even using the Admin theme for a page created with views?
Any help would be great.
Cheers, Garry.
it's in the path
When you create the page with Views you will need to add the path. Simply ensure the path starts with admin/... and it will use the admin theme.
You can just set the path to
You can just set the path to /admin but what if there are other pages that you want to have the admin theme like /node/edit . . ..
I needed to do this recently so knocked together this quick module, this hooks into the admin/build/themes/admin page. You will see 2 custom text areas, one for pages that you want to force to use your sites theme and one for pages that you want to use the admin theme. Works fine most pages but dont use it for the blocks page as this won't show your blocks.
Hope this helps
<?php
/**
* Implementation of hook_init().
*/
function admin_theme_additions_init() {
$admin_theme_disallow = FALSE;
$admin_theme = FALSE;
// check if some paths are disallow to get the theme
if (trim(variable_get('admin_theme_additions_path_disallow', '')) != '') {
// pages that are defined by their normal path
$admin_theme_disallow = drupal_match_path($_GET['q'], variable_get('admin_theme_additions_path_disallow', ''));
// pages that are defined with their alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme_disallow = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_additions_path_disallow', ''));
}
}
// we should not show the admin theme if the user has no access or the path is in the disallow list
if ($admin_theme_disallow) {
unset($GLOBALS['custom_theme']);
return;
}
// some custom defined pages should get admin theme
if (trim(variable_get('admin_theme_additions_path', '')) != '') {
// pages that are defined by their normal path
$admin_theme = $admin_theme || drupal_match_path($_GET['q'], variable_get('admin_theme_additions_path', ''));
// pages that are defined with their alias
$alias = drupal_get_path_alias($_GET['q']);
if ($alias != $_GET['q']) {
$admin_theme = $admin_theme || drupal_match_path($alias, variable_get('admin_theme_additions_path', ''));
}
}
// trun the admin theme on or off depedning on the results above
if ($admin_theme == TRUE){
_admin_init_theme();
}
}
function admin_theme_additions_form_system_admin_theme_settings_alter(&$form, $form_state) {
// allow the user to define a set of pages where the admin theme should or should not be applied to
$form['pages']['custom'] = array(
'#type' => 'fieldset',
'#title' => t('Custom pages'),
'#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '<front>')),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 9,
);
$form['pages']['custom']['admin_theme_additions_path'] = array(
'#type' => 'textarea',
'#title' => t('Use administration theme on the following pages.'),
'#default_value' => variable_get('admin_theme_additions_path', ''),
);
$form['pages']['custom']['admin_theme_additions_path_disallow'] = array(
'#type' => 'textarea',
'#title' => t('Do not use administration theme on the following pages.'),
'#description' => t('If a path appears here, the administration theme is not shown even if all above options apply.'),
'#default_value' => variable_get('admin_theme_additions_path_disallow', ''),
);
}
?>
Thanks
Thanks Darren, that's certainly worked for my view - so that's at least sorted.
Mike, do these text areas need to contain every page on your site then? I was wondering what would happen once I pass the site onto the editors - it wouldn't be appropriate for them to have to add the page into a text area so it would then display the correct theme.
Thanks for the replies anyway, much appreciated.
Garry.
quick update
Just for anyone who may be interested in the posts here. I have worked out an extremely untidy way to achieve a custom php/html admin page combing the use of Views and a custom template file. The purpose is purely to have a page existing with the Admin theme you have chosen, so you can add your own html or php to this page. My example will create a page that contains a list of links to edit different content types, insetad of forcing the user to use the "Edit Content" page. I'd much rather seperate these things out instead of showing the user a complex search and filter interface with all the content types.
Create a simple view, call it anything you like -
Add a page to display
Add the path as admin/whateveryoulike - mine is currently admin/edit-all (as it shows a list of content types)
Add a field for Node: type
Items to display: 1
In Theme:Information change the theme to use to your Admin theme. Mine is Rubik > Click "Change Theme"
Now copy the name of the last tpl file listed under "Row Style Output" - should be something like views-view-fields--myview--default.tpl.php
Create a new file in your /sites/all/themes/rubik folder called this and upload to your server.
Click "Rescan template files" - this should now emphasize "views-view-fields--myview--default.tpl.php" in your list of template files.
Click "Ok" and "Save"
Go to your template file that you created in the admin theme directory and enter your code into this. I simply put a html list into my file:
<ul>
<li><a href="#">Edit Pages</a></li>
<li><a href="#">Edit News Items</a></li>
<li><a href="#">Edit Events</a></li>
</ul>
Save and upload this file. Now if you go to yoursite.com/edit-all - then you should see your custom code displaying with the admin theme. You can now link users to this page via a menu item linking to /admin/edit-all (or whatever path value yo used in the view).
I know this is an extremely messy way to achieve this - but I can't think of anything else other than using a template file in a view. If anyone needs help, then I'll be glad to help.
Cheers, Garry.