Pagination Question

General ShopSite user discussion

Pagination Question

Postby tmlogo » Thu Aug 14, 2014 4:30 pm

If I have products on a page that allows pagination, is there anyway to have verbiage i.e. that is in a Text or Page Field area that only shows up on the first or last page and NOT all the pages?

Thanks in advance.
tmlogo
 
Posts: 110
Joined: Tue Jun 17, 2008 3:00 pm

Re: Pagination Question

Postby Jim » Fri Aug 15, 2014 8:01 am

There isn't a built in text field for that purpose but it would be possible to do something like that.
There are 2 template tags for pagination information. See the Page tags section of the template cheatsheet http://www.shopsite.com/help/12.0/en-US/templates/custom.template.cheatsheet.page.html
Code: Select all
Pagination Fields
[-- PAGE.PaginatedPageNum --]    Current page number when multipages/pagination is used.
[-- PAGE.PaginatedPageNumMax --]    Maximum number of pages when multipages/pagination is used.


So you could use those tags to see if you were on the the first or last page of the pagination pages and then out put some text which could be hard coded in the template or you could use one of the custom fields to contain the text and then insert that field.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Pagination Question

Postby tmlogo » Fri Sep 26, 2014 7:49 am

Hi Jim,

I haven't been able to try this coding until yesterday, and it is not working for me. At the present time I am using the following in my template and setting the number of products per page on the "Edit Page Layout" through Shopsite:

[-- IF PAGE.ProductsPerPage 0 --] 

[-- ELSE --]
[-- PrevNext --]
[-- END_IF --]

Not sure where to put and how to implement the commands you provided.

Thanks
tmlogo
 
Posts: 110
Joined: Tue Jun 17, 2008 3:00 pm

Re: Pagination Question

Postby Jim » Fri Sep 26, 2014 9:44 am

Try something like
Code: Select all
[-- VAR.CurrentPage PAGE.PaginatedPageNum --]
[-- VAR.MaxPage  PAGE.PaginatedPageNumMax --]

[-- IF VAR.CurrentPage EQ "1" --]
   output your first page info
[-- ELSE_IF VAR.CurrentPage EQ VAR.MaxPage --]
  output your last page info
[-- END_IF --]


You should put code like the above (I didn't test it to make sure it works) where ever you want the first/last page text to be output on the page.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Pagination Question

Postby tmlogo » Fri Sep 26, 2014 10:38 am

I don't mean to be "thick", but I haven't worked on templates for a while and am at a loss.

So to be safe, I can select any number for page max. (Normally we don't go beyond 10) Would this be the way it would be written? If I wanted the information (text) to appear only on the last page would it not appear if there were not 25 pages exactly? Do I need to know the exact number of pages before writing this code?

[-- VAR.CurrentPage PAGE.PaginatedPageNum 1 --]
[-- VAR.MaxPage PAGE.PaginatedPageNumMax 25 --]

[-- IF VAR.CurrentPage EQ "1" --]
(Would not need this line if only putting info on last page?)
[-- ELSE_IF VAR.CurrentPage EQ VAR.MaxPage --]
TEXT WOULD GO HERE FOR LAST PAGE ONLY
[-- END_IF --]
tmlogo
 
Posts: 110
Joined: Tue Jun 17, 2008 3:00 pm

Re: Pagination Question

Postby Jim » Fri Sep 26, 2014 1:41 pm

You should not put the 1 or 25 like you have
Code: Select all
[-- VAR.CurrentPage PAGE.PaginatedPageNum --]
[-- VAR.MaxPage PAGE.PaginatedPageNumMax --]


The PAGE.PaginatedPageNum part of the VAR.CurrentPage statement will set the VAR.CurrentPage value equal to whatever the current pagination page number is.
Same for the next statement, PAGE.PaginatedPageNumMax will return the max number of pages that will be generated. So if you have 40 products assigned to the page and you set it to have 5 products on the page then it would return 8. So if you had Utility > Publish > max pages set to 10 the code should still put your message on the last page (8) generated. If you have more products (say 55) then all the extra products would be appended to page 10 and that would be where your message would be displayed.
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Re: Pagination Question

Postby tmlogo » Fri Sep 26, 2014 2:02 pm

Thank you. I will give it a try. :-)
tmlogo
 
Posts: 110
Joined: Tue Jun 17, 2008 3:00 pm


Return to User Forum

Who is online

Users browsing this forum: No registered users and 64 guests