Alex,
Some things, once you start thinking about them, seem better off in the template and template parser, than in the code, or plug-in module, especially a _display hook, that will go off each time, whether needed or not.
Specfic example:
With the multiple attachments module, I need a whole bunch of _display hooks, but mainly have to worry about link.html and detailed.html where the "link" data is being processed.
If a link "hasAttachments" then I need to do a "select" from the attachments table, and create an array of hashes "elements" for the <%loop%> routine, just like for link_results.
Would it be "better" to do this in the template, where "hasAttachments" can actually be checked? Or would it be better off as a _display call, that is executed for every "link" and which has to check whether "hasAttachments" is positive?
<%if hasAttachments%>
<%execute function get_attachments%>
<%loop elements%>
<%include element.txt%>
<%endloop%>
<%endif%>
Or, via the _display hook: "get_attachments"
my $link =shift;
if ($link->{'hasAttachments'}) {big do block of code}
return $link;
and then:
<%if elements%>
<%loop elements%>
<%include element.txt%>
<%endloop%>
<%endif%>
??
The template version has obvious appeal, but is that expecting too much of the template parser, and the plug-in call is "less expensive" even if called when not needed?
BTW... I could add functions to the template global.txt file during install, by reading in that file with the datadumper code, checking for the existence of the tag I want to add, adding the tag, then dumping it back out, right?? No problems there?? (obviously, default template set only)
PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum
Some things, once you start thinking about them, seem better off in the template and template parser, than in the code, or plug-in module, especially a _display hook, that will go off each time, whether needed or not.
Specfic example:
With the multiple attachments module, I need a whole bunch of _display hooks, but mainly have to worry about link.html and detailed.html where the "link" data is being processed.
If a link "hasAttachments" then I need to do a "select" from the attachments table, and create an array of hashes "elements" for the <%loop%> routine, just like for link_results.
Would it be "better" to do this in the template, where "hasAttachments" can actually be checked? Or would it be better off as a _display call, that is executed for every "link" and which has to check whether "hasAttachments" is positive?
<%if hasAttachments%>
<%execute function get_attachments%>
<%loop elements%>
<%include element.txt%>
<%endloop%>
<%endif%>
Or, via the _display hook: "get_attachments"
my $link =shift;
if ($link->{'hasAttachments'}) {big do block of code}
return $link;
and then:
<%if elements%>
<%loop elements%>
<%include element.txt%>
<%endloop%>
<%endif%>
??
The template version has obvious appeal, but is that expecting too much of the template parser, and the plug-in call is "less expensive" even if called when not needed?
BTW... I could add functions to the template global.txt file during install, by reading in that file with the datadumper code, checking for the existence of the tag I want to add, adding the tag, then dumping it back out, right?? No problems there?? (obviously, default template set only)
PUGDOGŪ Enterprises, Inc.
FAQ:http://LinkSQL.com/FAQ
Forum:http://LinkSQL.com/forum