And furthering my example, in that very same view I have another table that 
displays the same set of items in grid format. Note I included a counter "i" 
and a "modulo 4" to insert a </tr><tr> to break it up into rows of 4 
columns. Also note the logic that inserts a placeholder image if an image is 
not present.

So it's not that there is no logic in the view, it's just keeping it sort of 
minimal. Also, I expect to move the styles into css files at some point.


    <table>
        <tbody>
        {{if len(items)==0:}}
            <tr><td colspan=4 align=middle><br>No items</td></tr>
        {{else:}}
            <tr>
                {{i=1}}
                {{for item in items:}}
                 <td width="180">
                    <p>{{if len(item.image)==0:}}
                           
 {{=A(IMG(_src=URL('static','images/no-photo.png'), _width='160px'), 
_href=URL(c='default', f='item', extension='', args=item.id, ))}}
                        {{else:}}   
                            {{=A(IMG(_src=URL(c='default', f='download', 
args=item.image), _width='160px'), _href=URL(c='default', f='item', 
extension='', args=item.id))}} 
                        {{pass}}</p>
                    <p style="min-height: 34px;">{{=A(item.title, 
_href=URL(c='default', f='item', extension='', args=item.id))}}</p>
                    <p><table width="100%"><tr><td style="padding: 2px 0px 
2px 2px;"><b>${{=item.current_price}}</b><br></td>
                    <td align=right style="padding: 2px 8px 2px 
2px;">${{=item.last_price}} on {{=item.last_date}}</td></tr></table>
                 </td></p>
                    {{if i%4==0:}}
                        </tr>
                        <tr>
                    {{pass}}
                    {{i+=1}}
                {{pass}}
            </tr>
        {{pass}}
        </tbody>
    </table>

Reply via email to