Firefox PHP

Hook Request: tpl_cc_start

Posted by Joe Curia 
Hook Request: tpl_cc_start
June 21, 2008 07:00PM
In coding my Enhanced Custom Profile mod I found it very easy to use the tpl_cc_usersettings hook in the cc_usersettings.tpl file to place profile fields for editing in the appropriate Control Center panels. However, when I went to display the content of those fields in the "View My Profile" panel, through cc_start.tpl, I found that there was no similar hook. I was able to use another hook to redirect to a custom cc_start.tpl template in my mod, however it would have been much simpler if there was a tpl_cc_start hook similar to the tpl_cc_usersettings hook. I think such a hook would be of value to future developers, making it much easier to access the "View My Profile" page without having to create separate template files for each new template.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Hook Request: tpl_cc_start
June 22, 2008 07:03AM
The problem with such hook would be that it would be against the unwritten template hook regulations.

Somewhere in the past, the development team agreed to only use template hooks for extending forms.One of the reasons is to prevent a wild growth of template hooks in the templates. The more template hooks, the more template hooks can be forgotten by module authors. Back then we decided that it would be better if the module install description would include instructions for enabling the template part of the module if template output was required. A good reason for this was that this way, module authors would not get in the way of template authors by providing some blob of HTML code that did not match the template (e.g. somebody providing an emerald compatible piece of HTML, while the template author has a template based on the classic template).

By now, we have module templates, which can be used to let a module output different HTML code for different templates. So this can be used to overcome one of the problems that we saw with template hooks.

Still, I think we should not go wild on template hooks. But I do agree that for the profile viewing screens (cc_start.tpl and profile.tpl) it might be a good idea to have a hook in there that can be used to add dynamic profile data to the output. If the rest of the team agrees on this, we can add some hooks to the templates.

Solutions for now:
  • Add a hook or some template code to the profile viewing pages yourself and document it in the install instructions for your module.
  • Fallback on some javascript code to do the placement. You could for example use the before_footer hook to output the data that has to be added to the profile block inside some <div> container. After that code, add some javascript that picks up the <div> container and places it inside the correct parent. This is a trick that I used in the latest Jumpmenu Module.
If we add hooks, then it will probably be for 5.3, since a rule of thumb is that for stable releases, no changes are done to the database structure or templates, unless it is for bug fixing.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Hook Request: tpl_cc_start
June 22, 2008 07:20AM
First off, thanks for the detailed response. One of the things that continues to impress me about Phorum is how you developers have a reason behind everything you do and even everything you don't do.

Quote
Maurice Makaay
Add a hook or some template code to the profile viewing pages yourself and document it in the install instructions for your module.
This is the approach I've taken for now, and I've created my own cc_start.tpl's for the available templates to ease the install. For other templates I've included the instructions. It just pains me when I have to make an admin do something other than turn the module on :-)

Finally, thanks for reminding me about profile.tpl. I had evidently set my blinders to the cc_ files and forgot about that one. I guess the work of a mod dev is never done.

Thanks again for considering my request.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Hook Request: tpl_cc_start
June 22, 2008 07:32AM
Quote

It just pains me when I have to make an admin do something other than turn the module on

That is exactly what has driven a lot of module support development up to now ;-)

And things will improve even further. To give you an example: phorum 5.3 will have better support for having database files inside the module. You can add something like this to your info.txt:
dbversion: 2008062000

The module tree layout can look like this:
mods/
     modfoo/
            db/
               mysql.php
               postgresql.php
               upgrade/
                       mysql/
                             2008031800.php
                             2008031801.php
                             2008062000.php
                       mysql/
                             2008031800.php
                             2008031801.php
                             2008062000.php

Phorum will automatically load the required database backend code (mysql.php or postgresql.php in this example, which contain the functions for handling the queries for the custom database changes). It will also take care of the database version upgrades. This whole system makes it a lot easier to add some custom tables to the Phorum database and to work with them from the module code.

So far the shameless Phorum 5.3 plug ;-)


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login