Inderstanding IF / ELSE a bit better

General ShopSite user discussion

Inderstanding IF / ELSE a bit better

Postby ajhauser » Thu Dec 08, 2011 9:58 pm

I have the following code in my template so that I can style the "pagination" section with some spacing and a background image. However, the div is appearing on every page - not just pages with links to see more items.

An example of the incorrect look can be seen here:
http://brotherscountrysupply.com/store/legal-privacy.html

Can someone please help me figure out what I am doing wrong?
Thanks very much.

Code: Select all
<div class="ClearDivs">
        [-- IF PAGE.ProductsPerPage "0" --]
          [-- ELSE --]
            <div class="pagination">[-- PREVNEXT --]</div>
        [-- END_IF --]
</div><!-- ClearDivs -->
Website Design, Website Development, eCommerce and Hosting
ajhauser
 
Posts: 84
Joined: Tue Dec 06, 2011 4:18 pm
Location: Earlville - the land of Earls

Re: Inderstanding IF / ELSE a bit better

Postby ShopSite Lauren » Mon Dec 12, 2011 10:41 am

My guess is that you did a PowerEdit to have all pages display x products per page. That would mean that even pages that don't have any products on a page no longer have 0 in the pagination field but have x products per page. What I would suggest would be to add a check to see if the page has products assigned AND if the pagination field is at 0. That way, even if the pagination field is not 0, if it doesn't have any products, the pagination div won't be displayed.

[-- IF PAGE.NumProducts "0" --]
[-- ELSE_IF PAGE.ProductsPerPage "0" --]
[-- ELSE --]
<div class="pagination">[-- PREVNEXT --]</div>
[-- END_IF --]

in the newest release of ShopSite (which is what you have) there are new tag functions that can check things like greater than, less than, equal to, etc. One way you might want to do the code above is to first check if the number of products per page is less than or equal to the pagination products per page. What this will do is for categories where you do have pagination turned on, but you do not have enough products to take advantage of the pagination, then the DIV for the pagination won't be displayed either, even though the pagination is turned on for that page.

[-- IF PAGE.NumProducts LE PAGE.ProductsPerPage --]
[-- ELSE_IF PAGE.ProductsPerPage "0" --]
[-- ELSE --]
<div class="pagination">[-- PREVNEXT --]</div>
[-- END_IF --]
- ShopSite Lauren
Contact me for help with any of your
custom ShopSite template questions.
ShopSite Lauren
 
Posts: 889
Joined: Fri Aug 11, 2006 1:35 pm
Location: Orem, UT

Re: Inderstanding IF / ELSE a bit better

Postby ajhauser » Thu Jan 19, 2012 12:28 am

I am at a loss. This worked perfectly, I just now implemented it. Thank you so much!!
Website Design, Website Development, eCommerce and Hosting
ajhauser
 
Posts: 84
Joined: Tue Dec 06, 2011 4:18 pm
Location: Earlville - the land of Earls


Return to User Forum

Who is online

Users browsing this forum: No registered users and 86 guests