[RFC|Rejected] hook_template_snippet

These event requests have either been rejected by the community or have become redundant because of code changes or other events requests.
Post Reply
User avatar
Kellanved
Former Team Member
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

[RFC|Rejected] hook_template_snippet

Post by Kellanved »

Name: hook_template_snippet
Rationale: It's hard to deploy small markup additions over several templates. This hook enables code to inject code prior to template compilation, allowing MODs to alter several templates without changes to the actual template files. By using includes, these snippets can use template-dependent snippets.
Input:
  • region: The name of the region where the snippet should be placed
Output:
  • snippet: The actual snippet to be included
Placement: In the template compiler
Semantics: The return value gets stored in a region => HTML array and then embedded into the template on compile.
Infrastructure: Termplate syntax has to be extended to have a region marker construct. Such region markers have to be placed throughout template files. The template compiler has to be extended to understand regions and embed the snippets.
Related: viewtopic.php?f=84&t=32796

Please post your RFCs for template regions in this topic
No support via PM.
Trust me, I'm a doctor.

sajaki
Registered User
Posts: 86
Joined: Mon Jun 21, 2010 8:28 pm

Re: [RFC] hook_template_snippet : Injecting code into the te

Post by sajaki »

hmm. this sounds useful. Since 90 % of mods touch overall_header, i think this may possibly eliminate mod conflicts in templates.

User avatar
ameeck
Registered User
Posts: 86
Joined: Sun Nov 13, 2005 6:43 pm
Location: Prague, Czech Republic
Contact:

Re: [RFC] hook_template_snippet : Injecting into the templa

Post by ameeck »

Region: HTML <head>
Use: Injecting additional content into the page header, e.g.:
  • Custom CSS files
  • JavaScript library inclusions
  • Additional meta tags
Please think before you post.

Nelsaidi
Registered User
Posts: 122
Joined: Tue Nov 11, 2008 5:44 pm

Re: [RFC] hook_template_snippet : Injecting into the templa

Post by Nelsaidi »

Cant you have a Template::add_script($url, $param1, $etc) method (and et cetra) for the above purposes?

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: [RFC] hook_template_snippet : Injecting into the templa

Post by nickvergessen »

Region: overall_header.html next to the FAQ-Link
Use: Adding a new link to a MOD-Page, as part of this hook: viewtopic.php?f=111&t=33714
Member of the Development-TeamNo Support via PM

Derky
Development Team
Development Team
Posts: 18
Joined: Sat Oct 08, 2005 7:50 pm
Location: Netherlands
Contact:

Re: [RFC] hook_template_snippet : Injecting into the templa

Post by Derky »

ameeck wrote:Region: HTML <head>
Use: Injecting additional content into the page header, e.g.:
  • Custom CSS files
  • JavaScript library inclusions
  • Additional meta tags
  • Additional Feeds
    Preferably below the current feeds.
Region: overall_footer.html next to the powered by phpBB copyright
Use: Injecting additional content into the footer like copyrights

Michaelo
Registered User
Posts: 106
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin

Re: [RFC] hook_template_snippet : Injecting into the templa

Post by Michaelo »

This should not require a specific hook...

An assign_block_vars hook should deal with adding content no matter where it is called from...
For example, the following would work for all instances:

Code: Select all

 hook_assign_block_vars('page', 'location', 'array_name');
Where the page would be the current phpbb page, the location could identify header, footer, block, body, etc. and of course the array_name equals the array to modify...

Notes:
  • phpBB is page orientated so adding the current page makes perfect sense...
    Adding a location identifier would allow a simple switch process in the mods hooked file to allowing storing of all potential edits in on file...
    In reality there is going to be a lot of unique hooks but common hooks would IMHO satisfy most mod edits...
Possible hook code...

Code: Select all

if(!function_exists('hook_assign_block_vars_mymod'))
{
    function hook_assign_block_vars_mymod($array_name)
    {
        if ($page == 'viewtopic')
        {
            switch ($location)
            {
                case 'head';
                    $template->assign_block_vars($array_name, array(
                        'BLOCKS'        => $value,
                        'BLOCK_ID'        => $block_id,
                        'BLOCK_TITLE'    => $block_title,
                    ));
                break;

                case 'body';
                    ...
                break;

                case 'footer';
                    ...
                break;

                case 'block';
                    ...
                break;

                case default;
                    ...
                break;
            }
        }
    }
}
I'm not sure how the hook management will be implementation but for the purposes of this example lets assume the mod provides an array of function calls, dependencies and priorities... The hook manager would then be responsible for linking the correct hook to the correct function and in the right sequence. If the dependencies were not met, the hook would not be implemented...
Mods: Forum Icons Enhancement, Kiss Portal Engine
Links:
Kiss Portal Engine (dev site) Stargate Portal (archive site) ...
Styles: Technika

User avatar
MichaelC
Development Team
Development Team
Posts: 889
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC|Rejected] hook_template_snippet

Post by MichaelC »

No longer relevant
Formerly known as Unknown Bliss
psoTFX wrote: I went with Olympus because as I said to the teams ... "It's been one hell of a hill to climb"
No unsolicited PMs please except for quotes.

Michaelo
Registered User
Posts: 106
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin

Re: [RFC|Rejected] hook_template_snippet

Post by Michaelo »

18 months for a reply... that's gota be a record ;)
Mods: Forum Icons Enhancement, Kiss Portal Engine
Links:
Kiss Portal Engine (dev site) Stargate Portal (archive site) ...
Styles: Technika

Post Reply