Welcome to Geeklog, Anonymous Wednesday, February 01 2023 @ 06:24 pm 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
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'];
        }
    }
 
Step #2 Modify lib-admin.php Change the lines 80 and 287 from
Text Formatted Code

$admin_templates = new Template($_CONF['path_layout'] . 'admin/lists');
 
to
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');
    }
 
Step #3 Remove admin templates of themes ** other than Professional theme **
-- mystral-kk, "Every cloud has a silver lining."
 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.)
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.
 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.
 Quote

Status: offline

kino

Forum User
Newbie
Registered: 06/14/06
Posts: 14
Location:Japan
The purpose of this correction lies in fixing the template of the management screen.

It is possible to process at high speed in correcting in this place.
 Quote

All times are EST. The time is now 06:24 pm.

  • 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