What are tmpl_hook sections in templates?

Discussion in 'ISPConfig 3 Priority Support' started by kobuki, Oct 20, 2024.

  1. kobuki

    kobuki Member HowtoForge Supporter

    I haven't found anything about this in the ISPC 3 docs, nor in the vlibTemplate docs. I might be looking at the wrong places, though. Since they are placed in important positions in vhost.conf.master (the Apache 2 vhost template), I thought I could make use of them for some local config additions. Could anyone point me to the docs for this, or just explain how to use the hooks in ISPC? Thanks in advance.
     
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    What you are looking for are the template files for ISPConfig. You can find them here: https://git.ispconfig.org/ispconfig/ispconfig3/-/tree/develop/install/tpl?ref_type=heads

    When you download ISPConfig from the website you can find it under install/tpl/. There are multiple templates you can use to overwrite default options.

     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no documentation for tmpl_hook available and I don't think we currently use it in the main code somewhere. In general, template hooks in the server work like this:

    1) You create a custom server plugin.
    2) In that plugin, you create a function and subscribe that function to the action 'on_template_content_hook'. (hint, don't mix up actions and events, events are changes in a database table while actions can be freely raised by the system e.g. in a template hook).
    You function will get passed the template hook name and all variables of the template, see server/lib/classes/tpl.inc.php line 1074+

    Code:
    $result = $app->plugins->raiseAction('on_template_content_hook', array(
                    'name' => $name,
                    'namespace' => $namespace,
                    'vars' => $this->_vars
                ), true);
    so you have to decide based on the name of the hook and the variables if and what you want to return. The text that your function returns will get put in the place where the template hook placeholder is in the template.
     
  4. kobuki

    kobuki Member HowtoForge Supporter

    Thanks for the info. Yeah, I don't see it used anywhere in the code, hence the question. 2 template files seem to make use the feature, but since there's no code that would utilize them, they just seem to be ignored.
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    The template placeholders are just an option to allow users to customize the template further without having to edit the ISPConfig code or having to make a complete template. If they are not used, the placeholder is replaced with an empty string.
     

Share This Page