Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 07:29 am EST
Geeklog Forums
Automatic fall back to Professional theme in admin screen
Status: offline
mystral-kk
Site Admin
Admin
Registered: 03/19/06
Posts: 100
Location:Japan
kino, one of Geeklog.jp members, devised a nice way to automatically select the Professional theme in the admin screen when there are no corresponding files in the layout/some_theme/admin directory. This hack will save theme creaters the time and trouble to design admin screens, for few people will need special admin screens.
Step #1 Modify lib-common.php
Around line 329, add the following
// In case we find no admin templeate, we fall back to Professional theme automatically
if( strpos( $_SERVER['PHP_SELF'], '/admin/' ) !== false ){
if( is_dir($_CONF['path_layout'] . 'admin' ) === false ){
$_CONF['theme'] = 'professional';
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
}
Step #2 Modify lib-admin.php
Change the lines 80 and 287 from
$admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
to
// In case we find no admin templeate, we fall back to Professional theme automatically
if( is_dir($_CONF['path_layout'] . 'admin/lists' ) === false ){
$admin_templates = new Template($_CONF['path_themes'] . 'professional/admin/lists');
} else {
$admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
}
Step #3 Remove admin templates of themes ** other than Professional theme **
-- mystral-kk, "Every cloud has a silver lining."
Text Formatted Code
// In case we find no admin templeate, we fall back to Professional theme automatically
if( strpos( $_SERVER['PHP_SELF'], '/admin/' ) !== false ){
if( is_dir($_CONF['path_layout'] . 'admin' ) === false ){
$_CONF['theme'] = 'professional';
$_CONF['path_layout'] = $_CONF['path_themes'] . $_CONF['theme'] . '/';
$_CONF['layout_url'] = $_CONF['site_url'] . '/layout/' . $_CONF['theme'];
}
}
Text Formatted Code
$admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
Text Formatted Code
// In case we find no admin templeate, we fall back to Professional theme automatically
if( is_dir($_CONF['path_layout'] . 'admin/lists' ) === false ){
$admin_templates = new Template($_CONF['path_themes'] . 'professional/admin/lists');
} else {
$admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
}
-- mystral-kk, "Every cloud has a silver lining."
11
10
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Why only do it in admin?
Just modify Template.class.php slightly. (This is totally untested code.)
global $_CONF; // don't forget this
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/") {
$filename = $this->root."/".$filename;
/// add from here
if (!file_exists($filename) && isset($_CONF['path_default_theme'])) {
$filename = $_CONF['path_default_theme'] . $filename; // like all $_CONF['path...'] variables, it should end in a '/'
}
/// to here
}
if (!file_exists($filename)) {
$this->halt("filename: file $filename does not exist.");
}
return $filename;
}
Just set $_CONF['path_default_theme'] to $_CONF['path_layout'] in config.php. It remains your default theme when lib-common starts messing with the $_CONF['theme'] and $_CONF['path_layout'] variables.
Just modify Template.class.php slightly. (This is totally untested code.)
Text Formatted Code
function filename($filename) {global $_CONF; // don't forget this
if ($this->debug & 4) {
echo "<p><b>filename:</b> filename = $filename</p>\n";
}
if (substr($filename, 0, 1) != "/") {
$filename = $this->root."/".$filename;
/// add from here
if (!file_exists($filename) && isset($_CONF['path_default_theme'])) {
$filename = $_CONF['path_default_theme'] . $filename; // like all $_CONF['path...'] variables, it should end in a '/'
}
/// to here
}
if (!file_exists($filename)) {
$this->halt("filename: file $filename does not exist.");
}
return $filename;
}
Just set $_CONF['path_default_theme'] to $_CONF['path_layout'] in config.php. It remains your default theme when lib-common starts messing with the $_CONF['theme'] and $_CONF['path_layout'] variables.
11
9
Quote
Status: offline
jmucchiello
Forum User
Full Member
Registered: 08/29/05
Posts: 985
Rereading the OP I see we solve two different issues. My change could cause mixed themes where certain files are missing making stuff unreadable depending on how stuff gets inherited.
10
9
Quote
All times are EST. The time is now 07:29 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content