Welcome to Geeklog, Anonymous Sunday, November 24 2024 @ 01:35 am EST

Geeklog Forums

Simplifying theme mods


Status: offline

jmucchiello

Forum User
Full Member
Registered: 08/29/05
Posts: 985
I found this in the bounties discussion:
Quote by: ajzz

Easier Theme Upgrades (Core & Custom theme file separation)

Along the lines of lib-custom.php, which separates custom code from core files, all themes should have a "custom" or "local" folder in each theme directory where edited copies of theme files are kept, and used from preferentially, if present. This minimizes the effort of having a laundry list of backup files, or doing a diff with old template files each time you realize that the theme has to be upgraded.

With this format, one downloads the latest core theme (say professional) with all the right admin files etc, and just copy over the custom directory from older versions.
1. Is it going to stop one from having to redo style.css, header.thtml and other usual suspects with files from the new template? - Probably not.
2. Does it make sure you have all the latest admin templates? Yes.
3. Does it make changes more traceable when multiple admins are changing templates? Yes.
4. Does it make theme development easier? Perhaps.

(There seem to be quite a few theme updates with recent versions - I recently gave up on a custom theme - a hacked GL1.3.6 version of aeon - and ended up modding the latest professional theme because upgrading the old theme seemed too daunting).

What if every theme directory contained a "custom subdirectory"? The theme would first look in $_CONF['path_layout'] . 'custom' for the thtml files. If it wasn't there, it would look go back to the normal directory to find the file. This idea won't help with images, css or javascript files but the thtml is usually the hardest thing to port.

Here's my idea for a fix: modify the template class in system/classes/template.class.php.
Text Formatted Code
  function filename($filename) {
    if ($this->debug & 4) {
      echo "<p><b>filename:</b> filename = $filename</p>\n";
    }

// this is new
    if (file_exists($this->root . "/custom/$filename")) {
        return $this->root . "/custom/$filename";
    }
// end of new

    if (substr($filename, 0, 1) != "/") {
      $filename = $this->root."/".$filename;
    }

    if (!file_exists($filename)) {
      $this->halt("filename: file $filename does not exist.");
    }
    return $filename;
  }
The nice thing about this fix is it works for files in the /layout/theme/ directories and in the /plugin/plugin_name/templates/ directories. The theme maker should include the custom directories in the tarball (and those directories should contain appropriate index.html files (which, sadly professional seems to be missing).
 Quote

All times are EST. The time is now 01:35 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