Adding Theme Switch for Dashboard
JuliaKM - September 10, 2007 - 21:26
| Project: | CiviCRM Theme |
| Version: | 5.x-1.0 |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
The theme switcher is working great for the pages have have "admin" in the URL. However, there seems to be quite a few pages that are really admin pages but fall under the User theme such as the Dashboard. It would be great if these pages could be controlled by the admin theme as well.

#1
I hadn't considered the dashboard as an admin page, but I guess that it usually is. Are there other pages you are thinking about?
I've temporarily added this as an option, but I'm not sure that I like it. Rather than commit it to CVS right now, I'm attaching it as a patch here. Feel free to try it out.
#2
#3
Thanks! That was really fast. Here are other pages that I think could be included in the admin theme:
civicrm/event?reset=1
civicrm/contact/view?reset=1&cid=(Contact Id)
civicrm/import?reset=1
civicrm/contribute?reset=1
civicrm/mailing?reset=1
civicrm/mailing/send?reset=1
civicrm/member?reset=1
civicrm/member/search?reset=1
civicrm/event?reset=1
I am just learning CiviCRM, but it seems like the pages that include "reset=1" and do not include any further text could be considered admin. Is there any easy way to force that these always be displayed with the admin theme?
#4
I don't think that the reset=1 is going to be the right thing to check. I was hoping that we might be able to use the user access permissions to determine what the site administrator has defined as "admin" verses available to users. But that's problematic because we really don't know which role is the "admin" role. As I said before, I'm not sure that the admin settings interface is the best choice either. But that might be the only fall-back.
I'll ask some more experienced CiviCRM user's to comment...
#5
After thinking about it more, I realized that the only pages that are exposed to end users are contained in the directories of contribute and event. There might be another page or two hidden in there that I have overlooked.
I modified your _civicrm_theme_get_var function to default the contact, group, import, mailing and member $arg1 variables to the admin theme. Then, for the event theme, I added a $arg2 variable and have the admin theme showing when $arg2 is empty. When $arg2 shows and is info or register, then the normal theme displays. I don't have CiviContribute set up yet, so in the meantime I tried to use similar logic to what I am doing for event.
Here's the revised function. It still needs to be cleaned up quite a bit and integrated with checkboxes under CiviCRM Theme in the menu.
function _civicrm_theme_get_var() {
$arg1 = arg(1);
$arg2 = arg(2);
/*added contact, group, import, mailing, and member checks */
if ($arg1 == 'admin' || $arg1 == 'contact' || $arg1 == 'group' || $arg1 == 'import' || $arg1 == 'mailing' || $arg1 == 'member' || ($arg1 == 'event' && $arg2 == '') || ($arg1 == 'contribute' && $arg2 == '') || ($arg1 == 'dashboard' && variable_get('civicrm_theme_dashboard', 0))) {
return 'civicrm_admin_theme';
}
/*checking for contribution page*/
elseif ($arg1 == 'contribute' && $arg2 == 'transact'){
return 'civicrm_theme';
}
/*checking for event info and registration pages*/
elseif ($arg1 == 'event' && $arg2 == 'info'){
return 'civicrm_theme';
}
elseif ($arg1 == 'event' && $arg2 == 'register'){
return 'civicrm_theme';
}
else return 'civicrm_theme';
}
#6
For an approach that allows the user to choose which paths to define as 'public', see:
http://drupal.org/node/267355