The first 3 lines of your code snippet can be changed into:
{{for count, item in enumerate(news):}}
That is more pythonic. Using counter variable is the bad taste from C
era.
On Sep19, 3:32pm, Jason Brower <[email protected]> wrote:
> Hmm...
> Is this what you where thinking?
>
> On Sat, 2009-09-19 at 00:27 -0700, annet wrote:
> > I have a table which contains news items. In the view I would like to
> > display the first 6 items in full and limit the display of the next 18
> > items to their title. So something like:
>
> {{count = 0}}
> > {{for item in news:}}
>
> {{count += 1}}
> {{if count <= 6:}}<--------datailed stuff> <div class="newsitem">
> > <h5>{{=db.nieuws.publicatie_datum.formatter(item.publicatie_datum)}}
> > </h5>
> > <h2>{{=item.titel}}</h2>
> > {{if item.ondertitel:}}<h3>{{=item.ondertitel}}</h3>{{pass}}
> > {{=XML(item.korte_inhoud)}} <br />
> > <h4>{{=A('Lees meer',_onmouseover="this.style.cursor='pointer;",\
> > _onclick="javascript:newsdetails('%s')"%URL
> > (r=request,f='newsdetails',args=[item.id]))}}</h4>
> > </div>
>
> {{else:}}<------------- not so detailed stuff
> <div class="newsitem">
>
>
>
> > <h5>{{=db.nieuws.publicatie_datum.formatter(item.publicatie_datum)}}
> > </h5>
> > <h2>{{=item.titel}}</h2>
> > {{if item.ondertitel:}}<h3>{{=item.ondertitel}}</h3>{{pass}}
> > {{=XML(item.korte_inhoud)}} <br />
> > <h4>{{=A('Lees meer',_onmouseover="this.style.cursor='pointer;",\
> > _onclick="javascript:newsdetails('%s')"%URL
> > (r=request,f='newsdetails',args=[item.id]))}}</h4>
> {{pass}}
> > <!-- newsitem -->
> > {{pass}}
>
> > <table>
> > <tbody>
> > {{for item in news:}}
> > <tr>
> > <td>
> > {{=item.titel}}
> > </td>
> > </tr>
> > {{pass}}
> > </tbody>
> > </table>
>
> > I hope one of you could provide me with the correct for loop to make
> > this work.
>
> > Kind regards,
>
> > Annet.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---