denny/ShinyCMS

View on GitHub
root/shop/view_category.tt

Summary

Maintainability
Test Coverage
[%-    meta.wrapper = 'shop/wrapper.tt';
    meta.title   = category.name;
    meta.meta_keywords    = 'Shop, Buy, ' _ category.name;
    meta.meta_description = category.description;
%]

<h3>
    [% category.name | html %]
</h3>

[%- FOREACH shop_item IN shop_items.all %]
[%- IF shop_item.image %]
<p>
    <a href="[% c.uri_for( 'item', shop_item.code ) %]"><img src="[% c.uri_for( '/static/cms-uploads/shop-images/thumbnails', shop_item.image ) %]" alt="Image of [% shop_item.name | html %]" title="Click to enlarge"></a>
</p>
[%- END %]
<p>
    <a href="[% c.uri_for( 'item', shop_item.code ) %]">[% shop_item.name | html %]</a>
</p>
[%- IF shop_item.paypal_button %]
<p>
    [% shop_item.paypal_button %]
</p>
[%- END %]
[%- END %]

<p>
    <span class="small">
    Viewing items [% shop_items.pager.first %] to [% shop_items.pager.last  %]
    of [% shop_items.pager.total_entries %]
    </span>
</p>
[%- IF shop_items.count != shop_items.pager.total_entries %]
<p>
    <span class="small">
    <a href="[% c.uri_for( 'category', category.url_name ) %]">&laquo;</a>
    [%- FOREACH page IN [ shop_items.pager.first_page .. shop_items.pager.last_page ] %]
    [%- IF page == shop_items.pager.current_page -%]
    <b>[% page %]</b>
    [%- ELSE -%]
    <a href="[% c.uri_for( 'category', category.url_name, page ) %]">[% page %]</a>
    [%- END -%]
    [%- END %]
    <a href="[% c.uri_for( 'category', category.url_name, shop_items.pager.last_page ) %]">&raquo;</a>
    </span>
</p>
[%- END %]