From: Nathan V. <na...@th...> - 2001-06-08 17:42:54
|
On Thu, 7 Jun 2001, John Bafford wrote: > Hi all, > > I'm trying to coax slash into displaying story-related information > that isn't stored in the stories table. I was hoping to be able to > Is this possible at all? If not, is there a way to do a query > directly from the template system? It seems like that's possible, but > there doesn't seem to be much in the way of documentation for the > template syntax. You might look into the patch on the sourceforge bugs page to fix extracols support, but it won't exactly do what you want. It might be useful to study, though, since it is doing something similar. There are very good docs for the template markup at http://www.template-toolkit.org/docs/default/index.html You can access any of the Slash::DB methods within the templates with the Slash.db object after you've USEd Slash. (a real working example): [% USE Slash; # args are: columns, tables, where, other sth = Slash.db.sqlSelectMany( 'guide.sid, title, section', 'stories, guide', "stories.sid = guide.sid AND guide_parent_sid = '$story.sid'", 'ORDER BY title' ); story.extras.child_links = []; WHILE (c = sth.fetchrow_hashref); story.extras.child_links.push( Slash.linkStory({ link => c.title, sid => c.sid, section => c.section, }) ); END; # end while c IF story.extras.child_links; SET story.extras.child_links_lis = story.extras.child_links.join("<li>"); SET story.relatedtext = "$story.relatedtext <li> $story.extras.child_links_lis"; END; %] Slash::DB has a mockery of documentation in it, you usually have to read the code in Slash::DB::MySQL to figure out what the methods do and how to call them. I would guess that there is a performance penalty for doing this sort of thing in the templates, but there may not be, since the templates are cached and compiled just like the perl. But it is certainly more awkward using the Template directives, I think (witness the goofy string concatenation in the last three lines of the example). The server error logs provide useful debugging output if you make syntax errors in your templates. Good luck, nathan -- Nathan Vonnahme na...@th... senior web developer third sector technologies http://enteuxis.org/nathan http://thethirdsector.com |