Extending/Restructuring of the "Theme-Engine"

Discussion in 'Developers' Forum' started by cfoe, May 14, 2012.

  1. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    Hi Devs,

    I am developing a theme for ISPConfig 3.0.4.x (http://www.howtoforge.com/forums/showthread.php?t=57106) with a higher impact on the layout than "just" the files in "themes/theme-name/".

    I would propose a "little" change of the "theming-engine" which would make the ISPC-frontend more flexible and the file-structure more logical.

    move template files
    ISPC_WEB_PATH./themes/tmpl_var name="theme"/templates/$module/*​

    to not break all module files the class newTemplate must be changed to reflect the base-dir of
    ISPC_WEB_PATH./themes/tmpl_var name="theme"/

    What do you as experienced php-developers think about the complexity of this modification?

    Would be great to not "hack" the template files of all modules for the new theme and by this breaking the default-theme.
  2. falko

    falko Super Moderator ISPConfig Developer

    First, that would require quote some work, so that change is a rather big one.

    Second, if you want to modify a template, you have to do it once right now. With your proposal, you have to modify it for each theme.

    I understand your point, but I'm not sure if this is a good idea.
  3. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    I just thought a little bit more about the "problem".

    In a module file e.g. dashboard/dashboard.php
    loads the template-file from dashboard/templates/dashboard.htm

    public function newTemplate($tmplfile)
    "just" needs to add "(ISPC_WEB_PATH.)../themes/.$_SESSION['s']['theme']./" to the $tmplfile-var.

    -> themes/*theme-name*/templates/dashboard.htm

    In this case templates must be moved to the theme-folder but no modifications to modules are necessary.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Modules in ISPConfig are self contianed, this means that they shall have their own templates folder for their web forms. These templates are not part of the theme as they should exist only once for all themes and dont contain theming information or styles, otherwise it would be nescessary to edit every theme when we add a new field to a web form.

    Just an example:

    If you maintain a theme for ispconfig were then you would have to change your theme for every new feature that we add in ispconfig or your theme will stop to work corrcetly. And you will have to maintain different versions of your theme for ecah ispconfig version, I dont think that this is what most users want.

    Nevertheless we can add themes/*theme-name*/ to the paths were the template engine searches for files, but I'm not sure if this is a good idea as many users will start complaining here in the forum if they updated their ispconfig and it stops working then due to the fact that the theme does not support new features.
  5. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    The files in *module*/templates/ are theme files which define structure by using fieldsets, divs, hr and other html tags.
    For me all tags except for framing tags (like <li>) of data output should be considered theme. Especially <br> is totally killing themability -> not best practice.
    The module provides vars for output in various formats used in the theme.

    I hope you understand my critique the way it is intended. As constructive input. I am really interested in ISPC and just trying to help improve it.

    Since I have not heard back from you after my mail to devAtISPC.de let me say that I would be happy to do the major work for this modification as long as someone else provides the mod for the php class(es).

    Beside the modification I would like to smooth out the default theme. I found a lot of minor inconsistencies and errors in the template files while rebuilding them for my theme.
  6. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    Till was so nice to implement a little hook (http://bugtracker.ispconfig.org/inde...s&task_id=2289) to be release with 3.0.5 making it unnecessary to overwrite any template files of modules by custom themes.

    Is it also working for dashlets?
    I have another idea to make the themability one step better:
    in the dashboard.php dashlets are assigned to one of 2 columns. How about scraping the columns and defining the position by css?
    That would make it possible for custom modules to post dashlets to the dashboard without hacking the dashboard.php.
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    It should work for any kind of files that are processed by the templating engine.

    The current dashboard system has to be improved, using css would be quite nice.
  8. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    how about making the login module/page a lot more flexible by using themes/.$_SESSION['s']['theme']./templates/login.tpl.htm instead of main.tpl.htm for the login page?
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    After login, only the menus and the content is loaded into the page with ajax. So if you have a main template for the login page that differs from the normal main template, you will not see the normal main template as it is not loaded at all.
  10. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    That is not good. So it is really not easy changing the login. :(

    Two remarks about your switch:
    1. I would propose a code change:
      if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['theme'])) {
      is_file(ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/'.$_SESSION['s']['module']['name'].'/templates/'.$filename)) {
      if(isset($_SESSION['s']['module']['name']) && isset($_SESSION['s']['theme'])) {
      is_file(ISPC_THEMES_PATH.'/'.$_SESSION['s']['theme'].'/templates/'.$_SESSION['s']['module']['name'].'/'.$filename)) {
      That would save a few folders.
    2. Dashlets do not work.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

    1) In ISPConfig, every module shall hold its own form and list templates which are normally not part of a theme. So the the form and list template files of a module sall be in the templates folder of the module and not in a global theme folder so that a module can be easily installed by copying the mdule directory into the ispconfig wen folder.

    2) Please make a bugreport so we can check that for the 3.0.5 release.
  12. cfoe

    cfoe ISPConfig Developer ISPConfig Developer

    The code change just moves the alternate tmp files from
    /themes/*theme-name*/*module-name*/templates/*.* to
    I mean the switch is not replacing the tmp files in the module folder with the present alternative tmp files in the theme folder
  13. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, I misinterpreted your code. This chanke is fine for me.

    The switch should work for all template files. But if you make a bugreport, then we can chack that.

Share This Page