phpBB

Development Discussion Board

phpBB's testing ground of bleeding edge code
Advanced search

[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.

[RFC|Rejected] hook_template_snippet

Postby Kellanved » Fri Aug 20, 2010 2:01 pm

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.
User avatar
Kellanved
Registered User
 
Posts: 407
Joined: Sun Jul 30, 2006 4:59 pm
Location: Berlin

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

Postby sajaki » Fri Aug 20, 2010 7:12 pm

hmm. this sounds useful. Since 90 % of mods touch overall_header, i think this may possibly eliminate mod conflicts in templates.
sajaki
Registered User
 
Posts: 48
Joined: Mon Jun 21, 2010 8:28 pm

Re: [RFC] hook_template_snippet : Injecting into the templa

Postby ameeck » Fri Aug 20, 2010 9:15 pm

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.
User avatar
ameeck
Registered User
 
Posts: 86
Joined: Sun Nov 13, 2005 6:43 pm
Location: Prague, Czech Republic

Re: [RFC] hook_template_snippet : Injecting into the templa

Postby Nelsaidi » Fri Aug 20, 2010 11:51 pm

Cant you have a Template::add_script($url, $param1, $etc) method (and et cetra) for the above purposes?
Nelsaidi
Registered User
 
Posts: 122
Joined: Tue Nov 11, 2008 5:44 pm

Re: [RFC] hook_template_snippet : Injecting into the templa

Postby nickvergessen » Sat Aug 21, 2010 1:37 pm

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
cheers nickvergessen :geek:
Member of phpBB Development-Team
No Support via PM — My MODs for phpBB 3.0.x
User avatar
nickvergessen
Development Team
Development Team
 
Posts: 350
Joined: Sun Oct 07, 2007 11:54 am
Location: Esslingen, Germany

Re: [RFC] hook_template_snippet : Injecting into the templa

Postby Derky » Thu Aug 26, 2010 9:02 pm

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
User avatar
Derky
MOD Team
MOD Team
 
Posts: 17
Joined: Sat Oct 08, 2005 7:50 pm
Location: Netherlands

Re: [RFC] hook_template_snippet : Injecting into the templa

Postby Michaelo » Mon Jan 10, 2011 6:47 am

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...
Michaelo
Registered User
 
Posts: 103
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin

Re: [RFC|Rejected] hook_template_snippet

Postby MichaelC » Thu May 31, 2012 3:05 pm

No longer relevant
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.
User avatar
MichaelC
Website Team
Website Team
 
Posts: 797
Joined: Thu Jan 28, 2010 6:29 pm

Re: [RFC|Rejected] hook_template_snippet

Postby Michaelo » Fri Jun 01, 2012 2:50 am

18 months for a reply... that's gota be a record ;)
Michaelo
Registered User
 
Posts: 103
Joined: Thu Apr 01, 2004 7:56 am
Location: Dublin


Return to [3.x] Rejected Event Requests

Who is online

Users browsing this forum: No registered users and 1 guest