Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

It's an array of hash refs. That's how you get the named fields out.

my $hashref = { 'rows' => "$i $x", 'offset' => "offset $offset", 'i' => "$i", 'x' => $x, 'INTERFACE' => \@r, }; push(@total, $hashref);

That's looped over a bunch of test data and then fed to get_data_callback as $data. It's just test junk but works as expected.

<TD BGCOLOR=#ffffff><TMPL_VAR NAME="rows"></TD>

produces the correct data stored in the hashref listed above.

The documentation doesn't mention the ability to pass as hash to get_data_callback so I'm not sure how/if that would work.

I've also been poking over the Pager.pm code between work issues but nothing has jumped out at me yet. It seems like either it's not possible or it's just not in the code because it's a default or obvious how it's suppose to work. Just not obvious to me. :)

thanks for looking,

-Matt

-- And this works --

Gen some random headers and add them to an array of hashrefs:

my @headers = ("1","2", "three", "4", "blank", "blank", "blank", "desc +-1", "desc-2", "desc-3", "desc-4", "desc-5"); for (@headers) { my $href = { 'HEADER' => $_ }; push(@h, $href); };

Make the primary array of hashrefs:

my $hashref = { 'rows' => "$i $x", 'offset' => "offset", 'name' => "some data $i", 'x' => $x, 'INTERFACE' => \@r, }; push(@total, $hashref);

Create the HTML::Template setup:

my $template = HTML::Template->new( filename => 'testing.tmpl', die_on_bad_params => 0, associate => $query, );

Add the header array of hashrefs to the template. Might be able to do this at the same time as you create the $template.. but for some reason it didn't work the first time I tried it.

$template->param(HEADER => \@h );

That works with this Template:

<TMPL_VAR NAME="PAGER_JAVASCRIPT"> <FORM> <TABLE BORDER=0 BGCOLOR=#000000 WIDTH=100%> <TR><TD><TABLE BORDER=0 WIDTH=100%> <!-- TMPL_LOOP NAME="HEADER" --> <TH BGCOLOR=#ffffff><!-- TMPL_VAR NAME="HEADER" --></TH> <!-- /TMPL_LOOP --> </TR> <TMPL_LOOP NAME="PAGER_DATA_LIST"> <TR> <TD BGCOLOR=#ffffff><TMPL_VAR NAME="rows"></TD> <TD BGCOLOR=#ffffff><TMPL_VAR NAME="offset"></TD> <TD BGCOLOR=#ffffff><TMPL_VAR NAME="name"></TD> <TD BGCOLOR=#ffffff><TMPL_VAR NAME="x"></TD> <!-- TMPL_LOOP NAME=INTERFACE --> <TD BGCOLOR=#ffffff><!-- TMPL_VAR NAME="description" --></TD> <!-- /TMPL_LOOP --> </TR> </TMPL_LOOP> <TR><TD><TD BGCOLOR=#DDDDDD COLSPAN=15 ALIGN=CENTER> <TMPL_VAR NAME="PAGER_PREV"> <TMPL_VAR NAME="PAGER_JUMP"> <TMPL_VAR NAME="PAGER_NEXT"> </TD></TR> </TABLE> </TABLE> <TMPL_VAR NAME="PAGER_HIDDEN"> </FORM>

Gives me the correct <TH></TH> headers I want. Cool beans.

-Matt


In reply to Re^4: HTML::Template with HTML::Pager by flyby
in thread HTML::Template with HTML::Pager by flyby

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (14)
    As of 2014-12-19 15:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (85 votes), past polls