Menu

why doesn't this work?

2001-10-19
2001-10-22
  • Darren Rook

    Darren Rook - 2001-10-19

    push @shows,{'date' => $lastdate, 'ENTRY' => ['bands' => [@bands], 'songs' => [@songs], 'albums' => [@albums], 'labels' => [@labels], 'requests' => [@requests], 'specials' => [@specials]]};

    With the following Template:

    <TMPL_INCLUDE NAME="E:/mxs/new/www/backend/main.top.temp">

        <TMPL_LOOP NAME="LISTS">
          <P><TMPL_VAR NAME="date">
            <TMPL_LOOP NAME="ENTRY">
              <BR><TMPL_VAR NAME="bands"> / <TMPL_VAR NAME="songs"> / <TMPL_VAR NAME="albums"> / <TMPL_VAR NAME="labels">
            </TMPL_LOOP>

       </TMPL_LOOP> 

    <TMPL_INCLUDE NAME="E:/mxs/new/www/backend/main.bottom.temp">

    The 'date' entry in the LISTS loop works, but the ENTRY loop doesn't do anything.  In fact if I leave the ENTRY loop in all I get out of HTML::Template is a blank screen.

    Any help would be great!

    Thanks.

     
    • Darren Rook

      Darren Rook - 2001-10-20

      I've changed my perl code so it looks a little cleaner:

      This is how I push $dates_data:

      push(@{$dates_data},{ band => $artist ,song => $song, album=> $album, label=> $label, request=> $request, special=>$special });

      This is how I push @shows:

      push(@shows, {date => $lastdate, DATES-DATA => $dates_data });

      Here's the template:

      <TMPL_LOOP NAME="DATES">
      <P><TMPL_VAR NAME="date">
      <TMPL_LOOP NAME="DATES-DATA">
      <BR><TMPL_VAR NAME="band"> / <TMPL_VAR NAME="song"> / <TMPL_VAR NAME="album"> / TMPL_VAR NAME="label">
      </TMPL_LOOP>

      My output is that I see the first DATES loope, so I see the 'date' variable being displayed.  But it doesn't seem to process the 'DATES-DATA' so it must not be pushed right.

      I'm using Perl 5.6 on Win32 with Template::HTML 1.8.  Does this version of Teamplate::HTML not allow nested loops?

      Any help please.

      Thanks.

       
      • Andrey Melnikov

        Andrey Melnikov - 2001-10-22

        Hello,

        First, you didn't close one <TMPL_LOOP>.
        Second, are you sure that $dates_data is an arrayref? How did you create it? Try to push to plain @array. But don't forget to put 'my' when needed.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.