[geeklog-devel] Proposal: Plugin vars in templates

Blaine Lang devel at portalparts.com
Sat Aug 11 22:09:49 EDT 2007


Joe Mucchiello wrote:
 > There's really no place it shouldn't be called. Anywhere there's a 
final $T->parse(), there should probably be a call to 
PLG_templateSetVars just before it.

Not likely as we do not want to add the extra overhead of calling this 
plugin API and all the related plugin functions for every template and 
should be added where it's needed or makes sense.

 > I provided a convention for handling this. It wouldn't be hard to 
explain. Worst case, the plugin writers should be encouraged to use 
set_var('plg1', $content, true). If all plugins do that, {plg1} can be 
used by multiple plugins.
Likely would not work when my cart plugin uses {plg1} to add a shopping 
cart feature and the ratings plugin or other wants to add a formatted 
table with voting buttons and messes up the layout of a story. I'd still 
want more control over the story template and want to use a {cart} 
template var.

In the case of my cart plugin, I use an autotag anyways so the [cart] 
tag can be where the user wants it. In the case of the ratings plugin 
specifically, why not use a [ratings] autotag which the story author or 
forum post author can then use to add a formatted ratings block at the 
end of the story or in the middle. Not need then for a template variable.
> At 09:09 PM 8/11/2007, Blaine Lang wrote:
>> I don't see the need to add these generic template vars to all of our 
>> templates because there would likely just be confusion and collision 
>> when the ratings plugin uses {plg1} and myplugin uses {plg1}. A 
>> generic name is just confusing as to what is' being used for.
>
> I provided a convention for handling this. It wouldn't be hard to 
> explain. Worst case, the plugin writers should be encouraged to use 
> set_var('plg1', $content, true). If all plugins do that, {plg1} can be 
> used by multiple plugins.
>
>> The plugin API PLG_templateSetVars has been an excellent addition to 
>> GL and very flexible - granted you need to update a template to add 
>> the variable if it does not exist but it's not hard to distribute 
>> those updates or directions. If you don't have a plugin and want to 
>> use this feature which has been the case for me on a few projects, 
>> adding your code to CUSTOM_templateSetVars is straight forward and 
>> you can test for the template file you need to to set the new 
>> variables for.
>
> Asking admins to modify templates is inelegant. Granted, this is a 
> band-aid but how does it really hurt add the fields.
>
>> There just may be a few more places we want to add 
>> PLG_templateSetVars();
>
> There's really no place it shouldn't be called. Anywhere there's a 
> final $T->parse(), there should probably be a call to 
> PLG_templateSetVars just before it.
>
>
> ----
> Joe Mucchiello
> Throwing Dice Games
> http://www.throwingdice.com
> _______________________________________________
> geeklog-devel mailing list
> geeklog-devel at lists.geeklog.net
> http://eight.pairlist.net/mailman/listinfo/geeklog-devel
>
>



More information about the geeklog-devel mailing list