html-template-users Mailing List for HTML::Template (Page 41)
Brought to you by:
samtregar
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(42) |
Jul
(80) |
Aug
(77) |
Sep
(97) |
Oct
(65) |
Nov
(80) |
Dec
(39) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(63) |
Feb
(47) |
Mar
(45) |
Apr
(63) |
May
(67) |
Jun
(51) |
Jul
(78) |
Aug
(37) |
Sep
(45) |
Oct
(59) |
Nov
(50) |
Dec
(70) |
2004 |
Jan
(23) |
Feb
(90) |
Mar
(37) |
Apr
(53) |
May
(111) |
Jun
(71) |
Jul
(35) |
Aug
(58) |
Sep
(35) |
Oct
(35) |
Nov
(35) |
Dec
(20) |
2005 |
Jan
(51) |
Feb
(19) |
Mar
(20) |
Apr
(8) |
May
(26) |
Jun
(14) |
Jul
(49) |
Aug
(24) |
Sep
(20) |
Oct
(49) |
Nov
(17) |
Dec
(53) |
2006 |
Jan
(12) |
Feb
(26) |
Mar
(45) |
Apr
(19) |
May
(19) |
Jun
(13) |
Jul
(11) |
Aug
(9) |
Sep
(10) |
Oct
(16) |
Nov
(17) |
Dec
(13) |
2007 |
Jan
(9) |
Feb
(12) |
Mar
(28) |
Apr
(33) |
May
(12) |
Jun
(12) |
Jul
(19) |
Aug
(4) |
Sep
(4) |
Oct
(5) |
Nov
(5) |
Dec
(13) |
2008 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(16) |
May
(3) |
Jun
(1) |
Jul
(12) |
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(9) |
2009 |
Jan
(9) |
Feb
|
Mar
(10) |
Apr
(1) |
May
|
Jun
(6) |
Jul
(5) |
Aug
(3) |
Sep
(7) |
Oct
(1) |
Nov
(15) |
Dec
(1) |
2010 |
Jan
|
Feb
|
Mar
|
Apr
(9) |
May
|
Jun
|
Jul
(5) |
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
(3) |
Mar
|
Apr
(28) |
May
|
Jun
|
Jul
(3) |
Aug
(4) |
Sep
(3) |
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
(2) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Dale W. H. <dal...@in...> - 2004-09-28 12:27:13
|
What I am faced with is the SELECT constraints need to be dynamic and = the list could be up to 20 fields. When I output the rows, I need each = to split each column into a separate cell in a table. Here is what I = have done in the past, but I am trying to remove the HTML from the code: foreach $ar_row (@dbRows) { foreach $ar_column (@$ar_row) { # set color to (odd)white || (even)lt grey=20 $color =3D (&odd_or_even($count) =3D=3D 0) ? "#DDDDDD" : "#FFFFFF"; =20 $nameValue =3D ""; $columnHtml =3D ""; $columnHtml .=3D qq[ <TR BGCOLOR=3D"$color">\n]; #apply color to row my $adj_count =3D $count + 1; # inset row count as first column $columnHtml .=3D qq[ <TD>$adj_count</TD>\n];=20 my $col_count =3D 0; =20 foreach $column (@$ar_column) { if ($column eq "") # if cell is empty { $column =3D " \;"; } if ($col_count =3D=3D 0) # if first column, add as link to view part { $columnHtml .=3D qq[ <TD nowrap>]; $columnHtml .=3D qq[<A HREF=3D"javascript:goToViewPart('$column')" = TITLE=3D"View Part $column" STYLE=3D"color:#ff0000">$column</A>]; $columnHtml .=3D qq[ </TD>\n]; } else { $columnHtml .=3D qq[ <TD nowrap>$column</TD>\n]; $nameValue .=3D qq[$column\|]; } $col_count++; } $columnHtml .=3D qq[ </TR>\n]; $html .=3D $columnHtml; $count++; } } return ($html, $count); ____________________________________________________ Dale Hanzelka 480-970-0200 x932 Senior Application Specialist 480-970-1331 (fax) Intercept Technology Inc.(AZ) www.INTERCEPT.com Intercept Design Group www.InterceptDG.org =20 ----- Original Message -----=20 From: "John" <jo...@e-...> To: "'Dale W. Hanzelka'" <dal...@in...>; = <htm...@li...> Sent: Tuesday, September 28, 2004 3:22 AM Subject: RE: [htmltmpl] How to Put reference array in to structure fro = use in H::T? From what you have described, you don't need a nested loop, so something like this example should do: Pick up your data, you can use execute and fetchall_arrayref methods if that suits you better. my $resultref =3D $dbh->selectall_arrayref('SELECT name, age, sex FROM People'); die("Database Error: " . $dbh->errstr) unless defined $resultref; Then map the results into an array (This is all one line).=20 my @loop =3D map { { name =3D> $_->[0], age =3D> $_->[1], sex =3D> = $_->[2] } } @$resultref; Then send it to template. my $template =3D HTML::Template->new(filename =3D> 'whatever.tmpl'); $template->param(LOOP =3D> \@loop); print $template->output; In tmpl: <TMPL_LOOP NAME=3D"LOOP"> <TMPL_VAR NAME=3D"name"> - <TMPL_VAR NAME=3D"age"> - <TMPL_VAR NAME=3D"sex"><br> </TMPL_LOOP> Resulting HTML: Pete - 21 - Male<br> Sally - 26 - Female<br> Etc... Hope this helps. Cheers John -----Mensaje original----- De: htm...@li... [mailto:htm...@li...] En nombre de Dale W. Hanzelka Enviado el: lunes, 27 de septiembre de 2004 15:22 Para: htm...@li... Asunto: [htmltmpl] How to Put reference array in to structure fro use in H::T? I am using the Perl DBI to access a database. In particular, I' calling the fetchall_arrayref. How do I get the returned information into a usable structure so that I can loop through each row, then each column in the row? The returned info is as such: Reference --> Reference to Row0 --> ( col0, col1, col2, etc...) Reference to Row1 --> ( col0, col1, col2, etc...) etc... I can acceccs it using the below loop: foreach my $array (@array) { my($i, $j); for $i ( 0 .. $#{$array} ) { my $count =3D ($i + 1); print "ROW $count\t"; for $j ( 0 .. $#{$array->[$i]} ) { $array->[$i][$j] =3D "NULL" if ($array->[$i][$j] eq ""); print "$array->[$i][$j]\t"; } print "\n"; } } How do I get the information into correct structure to use as a nested loop in my template? Thanks in Advance! -Dale ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 =20 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 =20 ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users |
From: John <jo...@e-...> - 2004-09-28 10:23:04
|
From what you have described, you don't need a nested loop, so something like this example should do: Pick up your data, you can use execute and fetchall_arrayref methods if that suits you better. my $resultref = $dbh->selectall_arrayref('SELECT name, age, sex FROM People'); die("Database Error: " . $dbh->errstr) unless defined $resultref; Then map the results into an array (This is all one line). my @loop = map { { name => $_->[0], age => $_->[1], sex => $_->[2] } } @$resultref; Then send it to template. my $template = HTML::Template->new(filename => 'whatever.tmpl'); $template->param(LOOP => \@loop); print $template->output; In tmpl: <TMPL_LOOP NAME="LOOP"> <TMPL_VAR NAME="name"> - <TMPL_VAR NAME="age"> - <TMPL_VAR NAME="sex"><br> </TMPL_LOOP> Resulting HTML: Pete - 21 - Male<br> Sally - 26 - Female<br> Etc... Hope this helps. Cheers John -----Mensaje original----- De: htm...@li... [mailto:htm...@li...] En nombre de Dale W. Hanzelka Enviado el: lunes, 27 de septiembre de 2004 15:22 Para: htm...@li... Asunto: [htmltmpl] How to Put reference array in to structure fro use in H::T? I am using the Perl DBI to access a database. In particular, I' calling the fetchall_arrayref. How do I get the returned information into a usable structure so that I can loop through each row, then each column in the row? The returned info is as such: Reference --> Reference to Row0 --> ( col0, col1, col2, etc...) Reference to Row1 --> ( col0, col1, col2, etc...) etc... I can acceccs it using the below loop: foreach my $array (@array) { my($i, $j); for $i ( 0 .. $#{$array} ) { my $count = ($i + 1); print "ROW $count\t"; for $j ( 0 .. $#{$array->[$i]} ) { $array->[$i][$j] = "NULL" if ($array->[$i][$j] eq ""); print "$array->[$i][$j]\t"; } print "\n"; } } How do I get the information into correct structure to use as a nested loop in my template? Thanks in Advance! -Dale ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Html-template-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-template-users --- Incoming mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.768 / Virus Database: 515 - Release Date: 22/09/2004 |
From: Peter L. <pe...@pe...> - 2004-09-27 14:46:36
|
Krang v1.024 is now available. Notable changes in this release: - Added support for 'hidden' stories - stories that by default do not show up in most publish-time story searches. - Added krang_info - a new command-line script to determine Krang status. - Updated browser detection to explicitely support Mozilla, inline with expanded support for other browsers. - Re-structured documentation to help the learning curve. - Fixed a cross-site scripting vulnerability. - Numerous other bugfixes. Detailed change-log here: http://krang.sf.net/docs/changelog.html Krang is an Open Source web-publisher / content-management system designed for large-scale magazine-style websites. It is a 100% Perl application using Apache/mod_perl and MySQL, as well as numerous CPAN modules. Krang provides a powerful and easy to use story and media editing environment for magazine editors, as well as a complete template development environment for web designers. On the back-end, Perl programmers can customize Krang to control the data entered in the story editor and add code to drive the templates to build output. Krang can be enhanced with add-ons containing new skins and other new features. Krang easily handles large data sets and can manage multiple websites in a single installation. For more information about Krang, visit the Krang website: http://krang.sourceforge.net/ There you can download Krang, view screenshots, read documentation, join our mailing-lists and access the CVS tree. - the Krang team |
From: Dale W. H. <dal...@in...> - 2004-09-27 13:23:03
|
I am using the Perl DBI to access a database. In particular, I' calling = the fetchall_arrayref. How do I get the returned information into a usable structure so that I = can loop through each row, then each column in the row? The returned info is as such: Reference --> Reference to Row0 --> ( col0, col1, col2, etc...) Reference to Row1 --> ( col0, col1, col2, etc...) etc... I can acceccs it using the below loop: foreach my $array (@array) { my($i, $j); for $i ( 0 .. $#{$array} ) { my $count =3D ($i + 1); print "ROW $count\t"; for $j ( 0 .. $#{$array->[$i]} ) { $array->[$i][$j] =3D "NULL" if ($array->[$i][$j] eq ""); print "$array->[$i][$j]\t"; } print "\n"; } } How do I get the information into correct structure to use as a nested = loop in my template? Thanks in Advance! -Dale |
From: <hat...@tu...> - 2004-09-25 15:44:29
|
Hello Offer, Thursday, September 23, 2004, 5:56:33 PM, you wrote: OK> Hi, OK> Say I've for got the following parameter passed to my template: OK> names_loop => $names, OK> Where $names looks like: OK> $names = OK> [ OK> {name => name1}, OK> {name => name2}, OK> {name => name3}, OK> # ... 50 such names OK> ]; OK> What do I write in my template to print 3 names per line, for example? OK> Is this even possible or do I have to re-arrange my data? OK> I tried: OK> <tmpl_loop names_loop><tmpl_var name> <tmpl_var name> <tmpl_var name> OK> </tmpl_loop> OK> But that just printed each name 3 times :-( OK> Thanks in advance, try something like <TMPL_LOOP ROWS> <TMPL_LOOP COLS> <TMPL_VAR NAME> </TMPL_LOOP> <br> </TMPL_LOOP> where ROWS are like this: ROWS = [ { COLS => [ { NAME => 'name1' }, { NAME => 'name2' }, { NAME => 'name3' } ] }, { COLS => [ { NAME => 'name4' }, { NAME => 'name5' }, { NAME => 'name6' } ] } ] -- Best regards, Горький Юрий mailto:hat...@tu... |
From: Carl F. <ca...@fi...> - 2004-09-24 08:27:45
|
> The functionality seems useful. > > I do suggest using underscores to separate words in method names, rather > than CamelCaps. I believe the underscore style is more common on CPAN, > and is also what's recommended in "perldoc perlstyle": > > http://www.perldoc.com/perl5.8.0/pod/perlstyle.html > > While short identifiers like $gotit are probably ok, use underscores to > separate words. It is generally easier to read $var_names_like_this than > $VarNamesLikeThis, especially for non-native speakers of English. It's also a > simple rule that works consistently with VAR_NAMES_LIKE_THIS. > > Package names are sometimes an exception to this rule. Perl informally reserves > lowercase module names for "pragma" modules like integer and strict. Other > modules should begin with a capital letter and use mixed case, but probably > without underscores due to limitations in primitive file systems' > representations of module names as files that must fit into a few sparse bytes. > > #### > > Also, if this really does work fine outside of HTML::Template, consider > a more generic name, like CGI:: or HTML:: or WWW:: > > You will more easily attract users and contributors of other templating > systems (or no templating system!) this way. > > Mark Thanks for the good advice Mark. I will change the method names. I also realised yesterday that it would probably be best somewhere under HTML:: I'm toying with HTML::Menu::DateTime I'm also currently adding examples for Template::Toolkit to the POD. Thanks, Carl Franks |
From: Andrew B. <an...@br...> - 2004-09-23 16:34:25
|
On 9/23/04 at 4:56 PM, off...@gm... (Offer Kaye) wrote: > Hi, >=20 > What do I write in my template to print 3 names per line? HTML::Template::Expr will allow you to do stuff like: <TMPL_LOOP NAME=3D"MY_LOOP"> Do something with <TMPL_VAR NAME=3D"MY_VAR"> <TMPL_UNLESS EXPR=3D"(__counter__ % 3) || (__last__)">=20 <br> </TMPL_UNLESS> </TMPL_LOOP> Regards, Andrew |
From: Mark S. <ma...@su...> - 2004-09-23 16:01:05
|
On 2004-09-17, Jose Pedro Andres <ma...@de...> wrote: > > > Hi: > Excuse me if it isn't the appropiate list. > > I'm trying to use html::template witch CGI::Application, but i like to select > the html include dir in a config file. When i use: > > $template_dir = "/opt/test/html_head/"; > my $app = boxmodule->new( > TMPL_PATH => "$template_dir" > ); > > i always get an error when i try to select the html template file > as i suppoused, when i use TMPL_PATH => "$template_dir", all the includes of > html templates must look in this directory, but it always said me "can't > include file" The syntax you are using above looks correct. Could you provide more detail? The answer may be related to how you reference your include files from the parent template, for example. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer ma...@su... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . |
From: Mark S. <ma...@su...> - 2004-09-23 15:55:36
|
On 2004-09-22, Carl Franks <ca...@fi...> wrote: > Hi, > > I've written a module which I propose naming > HTML::Template::Dropdown::Date. > > Please see the POD below for description and usage. The functionality seems useful. I do suggest using underscores to separate words in method names, rather than CamelCaps. I believe the underscore style is more common on CPAN, and is also what's recommended in "perldoc perlstyle": http://www.perldoc.com/perl5.8.0/pod/perlstyle.html While short identifiers like $gotit are probably ok, use underscores to separate words. It is generally easier to read $var_names_like_this than $VarNamesLikeThis, especially for non-native speakers of English. It's also a simple rule that works consistently with VAR_NAMES_LIKE_THIS. Package names are sometimes an exception to this rule. Perl informally reserves lowercase module names for "pragma" modules like integer and strict. Other modules should begin with a capital letter and use mixed case, but probably without underscores due to limitations in primitive file systems' representations of module names as files that must fit into a few sparse bytes. #### Also, if this really does work fine outside of HTML::Template, consider a more generic name, like CGI:: or HTML:: or WWW:: You will more easily attract users and contributors of other templating systems (or no templating system!) this way. Mark -- . . . . . . . . . . . . . . . . . . . . . . . . . . . Mark Stosberg Principal Developer ma...@su... Summersault, LLC 765-939-9301 ext 202 database driven websites . . . . . http://www.summersault.com/ . . . . . . . . |
From: Jason P. <ja...@jo...> - 2004-09-23 15:50:36
|
What I've done in the past, where I need to have more than two in a row is to create a nested loop, where the outer loop is the rows and the inner loop is the 3 (or N != 2) records you want to display. Code Example (in the cgiapp): # Need to divide into sixths for Rosie's design... my $count = 0; my $six_issues = []; my $rows = []; while( my $hr = $sth->fetchrow_hashref() ) { $hr->{'bi_rate'} = sprintf( "%.2f", $hr->{'bi_rate'} ); $count++; my $img = 'graphics/TOC/' . sprintf( "%02d", $hr->{'volume_num'} ) . sprintf( "%02d", $hr->{'issue_num'} ) . '/cover-small.jpg'; push @$six_issues, { 'image_file' => $img, 'id' => $hr->{'id'}, 'label' => $hr->{'label'}, 'volume_num' => $hr->{'volume_num'}, 'issue_num' => $hr->{'issue_num'}, 'bi_rate' => $hr->{'bi_rate'}, }; if ( $count % 6 == 0 ) { push @$rows, { 'six_issues' => $six_issues }; $six_issues = []; } } push @$rows, { 'six_issues' => $six_issues } if ( $six_issues ); $template->param( 'rows' => $rows ); ---------------------- htmltmpl Code Example: ---------------------- <!-- TMPL_LOOP NAME="rows" --> <tr> <!-- TMPL_LOOP NAME="six_issues" --> <td valign="top" nowrap class="sansserif"><label for="ind_<!-- TMPL_VAR NAME="id" -->"><img src="<!-- TMPL_VAR NAME="image_file" -->" border="1" width="92" height="120"></label></td> <!-- /TMPL_LOOP --> </tr> <tr> <!-- TMPL_LOOP NAME="six_issues" --> <td valign="top" nowrap class="sansserif"><label for="ind_<!-- TMPL_VAR NAME="id" -->"><!-- TMPL_VAR NAME="label" --> <br> (Vol. <!-- TMPL_VAR NAME="volume_num" -->, Issue <!-- TMPL_VAR NAME="issue_num" -->)<br> <input type="checkbox" name="ind_issue" id="ind_<!-- TMPL_VAR NAME="id" -->" value="<!-- TMPL_VAR NAME="id" -->"> $ <!-- TMPL_VAR NAME="bi_rate" --> (USD)</label> </td> <!-- /TMPL_LOOP --> </tr> <!-- /TMPL_LOOP --> You can see this in action at our FB&C Subscription Website (it's the 2nd process {we don't collect your information from the first step -- it all becomes hidden variables at the bottom of that 2nd page}): http://www.finebooksmagazine.com/subscribe This is one of the limitations of HTML::Template, but it's also a bleed or merge of logic/control into the presentation layer. I (& you) might get tempted to move to something like TT, where you can put some logic in the template itself, but that's where you blur the lines of MVC. I would be interested to read other responses to this, too. Cheers, Jason PS: If you only wanted two, you could workaround it with the __EVEN__ and __ODD__ loop context variables. |
From: Mark S. <ma...@su...> - 2004-09-23 15:48:45
|
On 2004-09-23, Offer Kaye <off...@gm...> wrote: > Hi, > Say I've for got the following parameter passed to my template: > names_loop => $names, > > Where $names looks like: > $names = > [ > {name => name1}, > {name => name2}, > {name => name3}, > # ... 50 such names > ]; > > What do I write in my template to print 3 names per line, for example? > Is this even possible or do I have to re-arrange my data? > I tried: > <tmpl_loop names_loop><tmpl_var name> <tmpl_var name> <tmpl_var name> > </tmpl_loop> > > But that just printed each name 3 times :-( So you want your data to look like this? Name1 Name2 Name3 Name4 Name5 Name6 One option is to create a nested loop and send that data structure to the code. It will look like this: $names = [ { row => [ {name => name1}, {name => name2}, {name => name3}, ], }, { row => [ {name => name3}, {name => name4}, {name => name5}, ], }, ]; ### Alternatively, you could try the HTML::Template::Expr module (which I have never used). It should allow you to express logic like: "After after third table cell, end the current row and start a new one". (Hint: use the modulo operator: "%"). Mark |
From: Mark S. <ma...@su...> - 2004-09-23 15:33:56
|
On 2004-09-14, =?Windows-1251?B?w+7w/Oro6SDe8Ojp?= <hat...@tu...> wrote: > Hello html-template-users, > > I don't know anything about how html-template caches its templates. > > I'm using file_cache, and I have many templates for different > modules. I have two ways for handling it: > > 1. > > main.tmpl: > > <TMPL_INCLUDE "some_header.html"> > <TMPL_IF _MODULE_MODULE1><TMPL_INCLUDE "modules/module1.tmpl"></TMPL_IF> > <TMPL_IF _MODULE_MODULE2><TMPL_INCLUDE "modules/module2.tmpl"></TMPL_IF> My best understanding is that you only need to cache once, for the "parent" page, and not for the included templates as well. This is because the way the include system works, it's just as if the content in those files was actually in the parent document. Mark |
From: Roger B. W. <ro...@fi...> - 2004-09-23 15:31:23
|
On Thu, Sep 23, 2004 at 04:56:33PM +0200, Offer Kaye wrote: > >What do I write in my template to print 3 names per line, for example? What I tend to do is: In the data, put in a "linebreak" variable: $names = [ {name => name1}, {name => name2}, {name => name3, linebreak => 1}, etc. then use it in the template: <tmpl_loop names_loop><tmpl_var name> <tmpl_if name=linebreak><br></tmpl_if> </tmpl_loop> R |
From: Carl F. <ca...@fi...> - 2004-09-23 15:30:32
|
> Hi, > Say I've for got the following parameter passed to my template: > names_loop => $names, > > Where $names looks like: > $names = > [ > {name => name1}, > {name => name2}, > {name => name3}, > # ... 50 such names > ]; > > What do I write in my template to print 3 names per line, for example? > Is this even possible or do I have to re-arrange my data? > I tried: > <tmpl_loop names_loop><tmpl_var name> <tmpl_var name> <tmpl_var name> > </tmpl_loop> > > But that just printed each name 3 times :-( > > Thanks in advance, > -- > Offer Kaye > Offer, To get 3 items per line, yes, you'd have to manipulate the data before feeding it to the template. Into something like, $names = [ {name1 => name1, name2 => name2, name3 => name3}, {name4 => name4, name5 => name5, name6 => name6}, ]; However, you can print 2 items per line by switching on 'loop_context_vars' and doing something like, <TMPL_LOOP names_loop> <TMPL_VAR name> <TMPL_UNLESS __odd__><BR></TMPL_UNLESS> </TMPL_LOOP> or to create a table with 2 columns <table> <TMPL_LOOP names_loop> <TMPL_IF __odd__><tr></TMPL_IF> <td><TMPL_VAR name></td> <TMPL_UNLESS __odd__></tr>TMPL_UNLESS> </TMPL_LOOP> </table> Carl Franks |
From: Offer K. <off...@gm...> - 2004-09-23 14:57:35
|
Hi, Say I've for got the following parameter passed to my template: names_loop => $names, Where $names looks like: $names = [ {name => name1}, {name => name2}, {name => name3}, # ... 50 such names ]; What do I write in my template to print 3 names per line, for example? Is this even possible or do I have to re-arrange my data? I tried: <tmpl_loop names_loop><tmpl_var name> <tmpl_var name> <tmpl_var name> </tmpl_loop> But that just printed each name 3 times :-( Thanks in advance, -- Offer Kaye |
From: Carl F. <ca...@fi...> - 2004-09-22 09:48:40
|
Hi, I've written a module which I propose naming HTML::Template::Dropdown::Date. Please see the POD below for description and usage. The module doesn't actually require HTML::Template and could be used for other things, though this is the use it was created for and will be maintained and developed for. I asked a while ago for comments but unfortunately didn't hear anything back. This time I'm asking if there's any objections to using the namespace (suggestions for alternative names welcome), as I want to upload to CPAN as it's used in a larger app that I'll be releasing soon. Many thanks, Carl Franks =head1 NAME HTML::Template::Dropdown::Date =head1 SYNOPSIS use HTML::Template::Dropdown::Date; my $menu = HTML::Template::Dropdown::Date->new ( date => '2004-02-26', noSelect => 1, emptyFirst => ''); $menu->startYear(2000); $menu->endYear(2010); $menu->lessYears(1); $menu->plusYears(5); $menu->secondMenu; $menu->minuteMenu; $menu->hourMenu; $menu->dayMenu; $menu->monthMenu; $menu->yearMenu; =head1 DESCRIPTION Creates data structures suitable for populating HTML::Template templates with dropdown date and time menus. Allows any number of dropdown menus to be displayed on a page, each independantly configurable. =head1 MOTIVATION To keep the creation of HTML completely seperate from the program, to easily allow css styles, javascript, etc. to be added to individual menus. To make the creation of menus as simple as possible, with extra options if needed. Menus can be created as easily as: #!/usr/bin/perl use strict; use warnings; use CGI ':standard'; use HTML::Template; use HTML::Template::Dropdown::Date; my $tmpl = HTML::Template->new (filename => $filename); my $menu = HTML::Template::Dropdown::Date->new; $tmpl->param (day => $menu->dayMenu(), month => $menu->monthMenu(), year => $menu->yearMenu(), ); print header(); print $tmpl->output(); =head1 METHODS =head2 new() my $menu1 = HTML::Template::Dropdown::Date->new (date => $date, startYear => $start, endYear => $end, noSelect => 1, emptyFirst => 1); my $menu2 = HTML::Template::Dropdown::Date->new (lessYears => $less, plusYears => $plus); C<new()> accepts the following arguments (in the form of a hash or list): =over4 =item date Can be in any of the formats 'YYYY-MM-DD hh:mm:ss', 'YYYYMMDDhhmmss', 'YYYYMMDDhhmm', 'YYYYMMDDhh', 'YYYYMMDD', 'YYYYMM', 'YYYY', 'YYYY-MM-- DD', 'hh:mm:ss'. The date passed to C<new()> is used to decide which item should be selected in all of the *Menu methods. =item startYear, endYear, lessYears, plusYears The equivalent of calling the method of the same name. =item noSelect If true, ensures no item in any menu will be selected. =item emptyFirst If 'defined', will create an extra list item at the start of each menu. The form value will be the empty string (''), the value passed to C<emptyFirst('value')> will be the visible label for the first item (the empty string is allowed). =back =head2 startYear() $date->startYear(2004); Sets the absolute year that the dropdown menu will start from. =head2 endYear() $date->endYear(2009); Sets the absolute year that the dropdown menu will end on. =head2 lessYears() $date->lessYears(2); Sets the year that the dropdown menu will start from, relative to the selected year. =head2 plusYears() $date->plusYears(7); Sets the year that the dropdown menu will end on, relative to the selected year. =head2 secondMenu() minuteMenu() hourMenu() dayMenu() monthMenu() yearMenu() $tmpl->param (secMenu => $date->secondMenu(), minMenu => $date->minuteMenu(0), hourMenu => $date->hourMenu('-1'), dayMenu => $date->dayMenu('+1'), monthMenu => $date->monthMenu(12), yearMenu => $date->yearMenu(), ); Accepts a value that will override the date (if any) in the C<new()> method. Accepts relative values such as '+1' or '-1'. Returns an array-reference suitable for passing directly to $tmpl- >param(). =head1 EXAMPLES =head2 Templates The 'examples' folder in this distribution contains the files second.html, minute.html, hour.html, day.html, month.html and year.html. Simply copy these files into the folder containing the rest of your templates. =head2 Displaying date dropdown menus Contents of template file "date.html": <html> <body> <form method="POST" action=""> <TMPL_INCLUDE day.html> <TMPL_INCLUDE month.html> <TMPL_INCLUDE year.html> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> Contents of program file: #!/usr/bin/perl use strict; use warnings; use CGI ':standard'; use HTML::Template::Dropdown::Date; use HTML::Template; my $tmpl = HTML::Template->new (filename => 'date.html'); my $menu = HTML::Template::Dropdown::Date->new (date => '2004-04-01', lessYears => 2, plusYears => 0); $tmpl->param (day => $menu->dayMenu(), month => $menu->monthMenu(), year => $menu->yearMenu(), ); print header(), print $tmpl->output(); =head2 Multiple Menus in a Single Page To create, for example, 2 'month' menus in a single page you could copy the month.html file to end_month.html and then change the line C<<select name="month">> in end_month.html to C<<select name="end_month">>. Then include both files in your main template: <html> <body> <form method="POST" action=""> <TMPL_INCLUDE month.html> <TMPL_INCLUDE end_month.html> <input type="submit" name="Submit" value="Submit"> </form> </body> </html> When this form is submitted, it will send 2 different values, 'month' and 'end_month'. =head1 DEFAULT VALUES If a date is not passed to the C<new()> or *Menu() methods, then C<localtime(time)> is called. If neither 'startYear' or 'lessYears' is set, the default used is C<lessYears(5)>. If neither 'endYear' or 'plusYears' is set, the default used is C<plusYears(5)>. =head1 EXPORT None. =head1 TIPS Years before 1000 AD passed to the C<new()> method in the 'YYYYMMDDhhmmss' format should be passed as strings, as the leading zeros are necessary. (e.g. '09990101000000'). Years before 1000 AD may be passed to the C<yearMenu()> method as literal numbers. Years before 1 AD are not allowed at all. DO NOT set both 'startYear' and 'lessYears' at the same time, it just doesn't make sense. DO NOT set both with 'endYear' and 'plusYears' at the same time, it just doesn't make sense. To start or end the range on the same year as selected, set lessYears or plusYears to zero, DO NOT set startYear or endYear to zero. When settting either 'startYear' or 'endYear', ensure that the selected year will fall within the range of years. When passing relative values to methods, ensure they are sent as strings. C<+1> numerically means C<1> which is not the same as the string C<'+1'>. If a date is set in C<new()> and either 'lessYears' or 'plusYears' set and then a value passed to the c<yearMenu()> method. The start / end year of the menu will be relative to the value passed to C<yearMenu()>, not the date set in C<new()>. 'Relative' parameter values sent to *Menu methods, which result in out-of-range selections are silently ignored and no item in the output menu will be selected. =head1 SEE ALSO HTML::Template =head1 AUTHOR Carl Franks =head1 COPYRIGHT AND LICENSE Copyright 2004, Carl Franks. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself (L<perlgpl>, L<perlartistic>). =cut |
From: Jose P. A. <ma...@de...> - 2004-09-17 21:42:46
|
Hi: Excuse me if it isn't the appropiate list. I'm trying to use html::template witch CGI::Application, but i like to select the html include dir in a config file. When i use: $template_dir = "/opt/test/html_head/"; my $app = boxmodule->new( TMPL_PATH => "$template_dir" ); i always get an error when i try to select the html template file as i suppoused, when i use TMPL_PATH => "$template_dir", all the includes of html templates must look in this directory, but it always said me "can't include file" any ideas or url about it ? thanks in advance ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. |
From: <hat...@tu...> - 2004-09-14 08:25:40
|
Hello html-template-users, I don't know anything about how html-template caches its templates. I'm using file_cache, and I have many templates for different modules. I have two ways for handling it: 1. main.tmpl: <TMPL_INCLUDE "some_header.html"> <TMPL_IF _MODULE_MODULE1><TMPL_INCLUDE "modules/module1.tmpl"></TMPL_IF> <TMPL_IF _MODULE_MODULE2><TMPL_INCLUDE "modules/module2.tmpl"></TMPL_IF> ... <TMPL_INCLUDE "some_footer.html"> and perl code like this: my $tmpl = HTML::Template->new( ... filename => 'main.tmpl', file_cache => 1, file_cache_dir => './cache/' ); $tmpl->param("_MODULE_$current_module" => 1); 2. main.tmpl: <TMPL_INCLUDE "some_header.html"> <TMPL_VAR MODULE_OUTPUT> <TMPL_INCLUDE "some_footer.html"> and perl code like this: my $tmpl = HTML::Template->new( ... filename => 'main.tmpl', file_cache => 1, file_cache_dir => './cache/' ); my $mod_tmpl = HTML::Template->new( ... filename => $module_tmpl, file_cache => 1, file_cache_dir => './cache/' ); $tmpl->param(MODULE_OUTPUT => $mod_tmpl->output()); so, the question is: is there a difference in this methods when caching? and what is better? (maybe there is a third way). thanks. -- Best regards, Горький Юрий mailto:hat...@tu... |
From: David W. <da...@ki...> - 2004-09-13 16:43:38
|
The Bricolage development team is pleased to announce the release of Bricolage 1.8.2. This maintenance release addresses quite a large number of issues in Bricolage 1.8.1. The most important changes were to enhance Unicode support in Bricolage. Bricolage now internally handles all text content as UTF-8 strings, thus enabling templates to better control the manipulation of multibyte characters. Other changes include better performance for searches using the ANY() operators and more intelligent transaction handling for distribution jobs. Here are the other highlights of this release: Improvements * Bricolage now runs under a DSO mod_perl as long as it uses a Perl compiled with -Uusemymalloc or -Ubincompat5005. See http://perl.apache.org/docs/1.0/guide/install.html#When_DSO_can_be_Us ed for details. * Alerts triggered to be sent to users who don't have the appropriate contact information will now be logged for those users so that they can see them and acknowledge them under "My Alerts". * Added bric_media_dump script to contrib/. * The category association interface used in the story profile when the ENABLE_CATEGORY_BROWSER bricolage.conf directive is enabled now uses radio buttons instead of a link to select the primary category. * Existing jobs are now executed within their own transactions, as opposed to no transaction specification. This means that each job must succeed or fail independent of any other jobs. New jobs are executed before being inserted into the database so as to keep them atomic within their surrounding transaction (generally a UI request). All this means that transactionality is much more intelligent for jobs and will hopefully eliminate job table deadlocks. * All templates now execute with UTF-8 character strings enabled. This means that any templates that convert content to other character sets might need to change the way they do so. For example, templates that had used <%filter> blocks to convert content to another encoding using something like Encode::from_to($_, 'utf-8', $encoding) must now use something like $_ = Encode::encode($encoding, $_), instead. Bric::Util::CharTrans should continue to do the right thing. * Added encoding attribute to Bric::Util::Burner so that, if templates are outputting something other than Perl utf8 decoded data, they can specify what they're outputting, and the file opened for output from the templates will be set to the proper mode. Applies to Perl 5.8.0 and later only. * Added SFTP_HOME bricolage.conf directive to specify the home directory and location of SSH keys when SSH is enabled. Bug Fixes * make clone once again properly copies the lib/Makefile.PL and bin/Makefile.PL files from the source directory. * Added missing language-specifying HTML attributes so as to properly localize story titles and the like. * The list of output channels to add to an element in the element profile now contains the name of the site that each is associated with, since different sites can have output channels with the same names. * The "Advanced Search" interface once again works for searching for related story and media documents. * Bricolage no longer attempts to email alerts to an empty list of recipients. This will make your SMTP server happier. * The version numbering issues of Bricolage modules have all been worked out after the confusion in 1.8.1. This incidentally allows the HTML::Template and Template Toolkit burners to be available again. * Misspelling the name of a key name tag or including a non-repeatable field more than once in Super Bulk Edit no longer causes all of the changes in that screen to be lost. * When a user overrides the global "Date/Time Format" and "Time Zone" preferences, the affects of the overrides are now properly reflected in the UI. * Publishing a story or media document along with its related story or media documents from a publish desk again correctly publishes the original asset as well as the relateds. * Deleted output channels no longer show up in the select list for story type and media type elements. * Deleting a workflow from the workflow manager now properly updates the workflow cache so that the deleted workflow is removed from the left navigation without a restart. * When Bricolage notices that a document or template is not in workflow or on a desk when it should be, it is now more intelligent in trying to select the correct workflow and/or desk to put it on, based on current workflow context and user permissions. * Content submitted to Bricolage in the UTF-8 character set is now always has the utf8 flag set on the Perl strings that store it. This allows fields that have a maximum length to be truncated to that length in characters instead of bytes. * Elements with autopopulated fields (e.g., for image documents) can now be created via the SOAP interface. * Fixed a number of the parameters to the list() method of the Story, Media, and Template classes to properly handle an argument using the ANY operator. These include the keyword and category_uri parameters. Passing an ANY argument to these parameters before this release could cause a well-populated database to lock up with an impossible query for hours at a time. * Template sandboxes now work for the Template Toolkit burner. For a complete list of the changes, see the changes list at http://www.bricolage.cc/news/announce/changes/bricolage-1.8.2/. For the complete history of ongoing changes in Bricolage, see Bric::Changes at http://www.bricolage.cc/docs/api/current/Bric::Changes. Download Bricolage 1.8.2 now from the Bricolage Website at http://www.bricolage.cc/downloads/, from the SourceForge download page at http://sourceforge.net/project/showfiles.php?group_id=34789, and from the Kineticode download page at http://www.kineticode.com/bricolage/index2.html. ABOUT BRICOLAGE Bricolage is a full-featured, enterprise-class content management and publishing system. It offers a browser-based interface for ease-of use, a full-fledged templating system with complete HTML::Mason, HTML::Template, and Template Toolkit support for flexibility, and many other features. It operates in an Apache/mod_perl environment and uses the PostgreSQL RDBMS for its repository. A comprehensive, actively-developed open source CMS, Bricolage was hailed as "Most Impressive" in 2002 by eWeek. Enjoy! --The Bricolage Team |
From: Brad C. <bra...@hi...> - 2004-09-11 17:18:27
|
> On Fri, Sep 10, 2004 at 02:11:03PM -0500, Brad Cathey wrote: >>> >>> you passed the array instead of the array reference >>> >>>> $template -> param(pagetitle => "Search Results", >>>> showlist => @$allshows); >>> ^^^^ >>> >>> this is probably the correct one: >>> >>> $template -> param(pagetitle => "Search Results", >>> showlist => $allshows); >> >> Well, now I get: >> >> "Single reference arg to param() must be a hash-ref! You gave me a ARRAY" >> >> I guess I don't know how to go from @$array to $array as a ref. A Perlie >> question. Maybe I need to head over to the Monastery. >> >> Again, the salient code is: >> >> my $allshows; >> >> push @$allshows, $sth->fetchall_arrayref({}); >> >> $template -> param( showlist => $allshows); > > I thought this was the same thing, but try using \@$allshows; maybe > there is some Perl conversion rule I don't understand causing $allshows > to be expanded to the array in a parameter context. > > For similar template loop vars I have, for instance, > > $template->param( "USERLIST_COL1", \@list ); > > but in this case the list was declared as an array rather than an array > ref. > -- Clifton Clifton, amazing. I added the slash and was golden. Thanks. |
From: Clifton R. <cli...@ti...> - 2004-09-11 01:10:13
|
On Fri, Sep 10, 2004 at 02:11:03PM -0500, Brad Cathey wrote: > > > > you passed the array instead of the array reference > > > >> $template -> param(pagetitle => "Search Results", > >> showlist => @$allshows); > > ^^^^ > > > > this is probably the correct one: > > > > $template -> param(pagetitle => "Search Results", > > showlist => $allshows); > > Well, now I get: > > "Single reference arg to param() must be a hash-ref! You gave me a ARRAY" > > I guess I don't know how to go from @$array to $array as a ref. A Perlie > question. Maybe I need to head over to the Monastery. > > Again, the salient code is: > > my $allshows; > > push @$allshows, $sth->fetchall_arrayref({}); > > $template -> param( showlist => $allshows); I thought this was the same thing, but try using \@$allshows; maybe there is some Perl conversion rule I don't understand causing $allshows to be expanded to the array in a parameter context. For similar template loop vars I have, for instance, $template->param( "USERLIST_COL1", \@list ); but in this case the list was declared as an array rather than an array ref. -- Clifton -- Clifton Royston -- cli...@ti... Tiki Technologies Lead Programmer/Software Architect Did you ever fly a kite in bed? Did you ever walk with ten cats on your head? Did you ever milk this kind of cow? Well we can do it. We know how. If you never did, you should. These things are fun, and fun is good. -- Dr. Seuss |
From: Brad C. <bra...@hi...> - 2004-09-10 23:38:35
|
> > you passed the array instead of the array reference > >> $template -> param(pagetitle => "Search Results", >> showlist => @$allshows); > ^^^^ > > this is probably the correct one: > > $template -> param(pagetitle => "Search Results", > showlist => $allshows); > > > Gabor > Well, now I get: "Single reference arg to param() must be a hash-ref! You gave me a ARRAY" I guess I don't know how to go from @$array to $array as a ref. A Perlie question. Maybe I need to head over to the Monastery. Again, the salient code is: my $allshows; push @$allshows, $sth->fetchall_arrayref({}); $template -> param( showlist => $allshows); Thanks all. |
From: Clifton R. <cli...@ti...> - 2004-09-10 18:16:00
|
On Fri, Sep 10, 2004 at 12:45:43PM -0500, Brad Cathey wrote: > Fellow H::Ters, > > Never got this error before. > > "HTML::Template->param() : You gave me an odd number of parameters to > param()!" In my experience this usually means that there has been an unintended type conversion, e.g. an intended hash has been collapsed to a list in a parameter reference somewhere, or a list to a series of parameters. > The only thing I can think of is that my AoH is wrong but Data::Dumper > shows: > > $VAR1 = [ { > 'id' => '6', > 'teaser' => 'Domestic violence has been called a serious health crisis.', > 'title' => 'Battered and Broken', > 'number' => '214' } ]; > > Ideas?? > > Thanks in advance, Brad > > > -------------------------------------------- > Here's my Perl (and yes, Data::Dumper shows all variables have values): > > for my $i ( 0 .. $#ids ) { > $stmt = "SELECT id,title,teaser,number FROM shows WHERE id = '$ids[$i]' > ORDER BY number"; > &execute_it( $stmt ); #db operations to grab all matches > > push @$allshows, $sth->fetchall_arrayref({}); > } > > $template = HTML::Template->new(filename => 'showslisting.tmpl', > die_on_bad_params => 0); > > $template -> param(pagetitle => "Search Results", > showlist => @$allshows); Bingo. This passes the (list) contents of the thingy $allshows points to as individual parameters to param(), rather than passing the reference to the list. You want to specify the parameter as simply $allshows. -- Clifton -- Clifton Royston -- cli...@ti... Tiki Technologies Lead Programmer/Software Architect Did you ever fly a kite in bed? Did you ever walk with ten cats on your head? Did you ever milk this kind of cow? Well we can do it. We know how. If you never did, you should. These things are fun, and fun is good. -- Dr. Seuss |
From: Gabor S. <ga...@pe...> - 2004-09-10 18:14:34
|
you passed the array instead of the array reference > $template -> param(pagetitle => "Search Results", > showlist => @$allshows); ^^^^ this is probably the correct one: $template -> param(pagetitle => "Search Results", showlist => $allshows); Gabor |
From: Brad C. <bra...@hi...> - 2004-09-10 17:45:54
|
Fellow H::Ters, Never got this error before. "HTML::Template->param() : You gave me an odd number of parameters to param()!" The only thing I can think of is that my AoH is wrong but Data::Dumper shows: $VAR1 = [ { 'id' => '6', 'teaser' => 'Domestic violence has been called a serious health crisis.', 'title' => 'Battered and Broken', 'number' => '214' } ]; Ideas?? Thanks in advance, Brad -------------------------------------------- Here's my Perl (and yes, Data::Dumper shows all variables have values): for my $i ( 0 .. $#ids ) { $stmt = "SELECT id,title,teaser,number FROM shows WHERE id = '$ids[$i]' ORDER BY number"; &execute_it( $stmt ); #db operations to grab all matches push @$allshows, $sth->fetchall_arrayref({}); } $template = HTML::Template->new(filename => 'showslisting.tmpl', die_on_bad_params => 0); $template -> param(pagetitle => "Search Results", showlist => @$allshows); ------------------------------------------- Here's my HTML <h1><tmpl_var pagetitle></h1> <tmpl_if showlist> <tmpl_loop showlist> <h4><a href="cgi-bin/showsum.pl?id=<tmpl_var name='id'>"> <tmpl_var name='title'></a></h4> <p><i>Show number:</i> <b><tmpl_var name='number'></b></p> <p class="spcb"><tmpl_var name='teaser'></p> </tmpl_loop> <tmpl_else> <p class="spcb">No shows matched.</p> </tmpl_if> |