Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Adding page numbers to multiple products view.

    I am trying add page numbers on the multiple products view listing. I know I have the built in page pagination that looks like this: [<< Prev] 1 2 3 4 5 ... [Next >>] that is also in use on product pages with multiple listings. At this point I would prefer to leave that alone if possible.


    What I would like to do is add the current page number and the maximum pages number to the pages that have multple products. So it looks like this:
    Page 3 of 10

    I am trying to have this display directly above or below the line that shows the page pagination. How can I add this to my multiple products view page when I have multiple pages?

  2. #2
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding page numbers to multiple products view.

    Quote Originally Posted by sports guy View Post
    I am trying add page numbers on the multiple products view listing. I know I have the built in page pagination that looks like this: [<< Prev] 1 2 3 4 5 ... [Next >>] that is also in use on product pages with multiple listings. At this point I would prefer to leave that alone if possible.


    What I would like to do is add the current page number and the maximum pages number to the pages that have multple products. So it looks like this:
    Page 3 of 10

    I am trying to have this display directly above or below the line that shows the page pagination. How can I add this to my multiple products view page when I have multiple pages?
    I'm not able at the moment to give full code, but at least some pseudo code/discussion.
    Basically, need the total number of items in the group (might be in the header_php.php file or other modules/pages/TOPIC file (TOPIC refers to whatever page is to be displayed)
    Then, need to know the number of items to be displayed on a page (already exists otherwise wouldn't be able to limit the number of items on the current page), then using divison and dropping the remainder and adding one if there is a remainder gives the total number of pages. As for the current page, well, since that is part of what is already displayed, would think that although may need to chase some code, that it's there.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  3. #3
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,931
    Plugin Contributions
    96

    Default Re: Adding page numbers to multiple products view.

    Not totally what you'd asked for, but you could peek at Product Pagination to see if it suits your needs. You can see it in action here.

  4. #4
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Adding page numbers to multiple products view.

    mc12345678,
    I am confused by your post.
    In the the first part "Basically, need the total number of items in the group (might be in the header_php.php file or other modules/pages/TOPIC file (TOPIC refers to whatever page is to be displayed)"

    I am unsure of what you are asking. Is there a setting in my control panel that gives this number? Would this group number change according to how many products in each category. The total number of items in group is confusing me. There are 10 products per page.

    As for yor second part: We are displaying 10 items per page.

    Lat10,
    I did look at the Product Pagination, I wish there were more options for that module or other modules with different features. This is a glorified version of the module that is already installed. They have identical information just displayed the same way:
    My display:
    [<< Prev] 1 2 3 4 5 ... [Next >>]
    Product Pagination Display:
    Previous 1 2 3 4 5 Next

    I agree it looks better than the base install however this still does not answer my problem.

    My client wants his page number to be listed like this:
    Page 3 of 10

    It doesn't look like this page Pagination has the flexibility to layout my page like above. I was hoping to use both, my current page pagination (built in) plus the page number listed below: Page 3 of 10

    My client feels the built in page numbering system is not clear. He would like to see what page number you are on in relation to the total number of pages for the product category we are on. Nothing more for this display.

  5. #5
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding page numbers to multiple products view.

    Quote Originally Posted by sports guy View Post
    mc12345678,
    I am confused by your post.
    In the the first part "Basically, need the total number of items in the group (might be in the header_php.php file or other modules/pages/TOPIC file (TOPIC refers to whatever page is to be displayed)"

    I am unsure of what you are asking. Is there a setting in my control panel that gives this number? Would this group number change according to how many products in each category. The total number of items in group is confusing me. There are 10 products per page.

    As for your second part: We are displaying 10 items per page.
    Okay, so a little background/explanation of where some of the data in ZenCart comes from. Whenever you are on a page in the store, there is a pages folder that is referenced. Files in the pages folder are run for all cases of the current page. If you are looking at all products for example, then the pages folder products_all is referenced. In products_all there is by default a header_php.php file. In that file are various variables that are created from other ZC available information. The applicable folder is also what is provided in the main_page= variable of the URL. So, if you look in the header_php.php file of includes/modules/pages/products_all you will find that a variable entitled $products_all_split is created based on the query of products to be displayed... If you look a little further, you see that $products_all_split is based on the split_page_results class found under includes/classes. As a result, the class has several operations that are available including pulling out the total number of pages and the current page number. so to display Page X of Y, you need only reference the $products_all_split->current_page_number and $products_all_split->number_of_pages for X and Y respectively. Then using standard ZC programming, you should use a language define to address the insert of the new text...

    So, back on the terminology, the group generically refers to all of the items in the item type that you are looking at. (So if looking at All items, then the group is all items, if looking at a category, then the group is all items in the category) As described above, the header_php.php file contains variables that are defined, therefore are "in" the file. The TOPIC file relates to what I describe above such as the includes/modules/pages/products_all where products_all would be the TOPIC.

    Looking a little further into the php standard, it appears that because the variables defined in the class split_page_results are not specifically defined as private, then they are publicly available using the calls above. So, pretty much it seems that all of the work is done already, just need to insert the code where desired, include CSS references, and then on each page load things are updated.

    Quote Originally Posted by sports guy View Post
    My client wants his page number to be listed like this:
    Page 3 of 10

    It doesn't look like this page Pagination has the flexibility to layout my page like above. I was hoping to use both, my current page pagination (built in) plus the page number listed below: Page 3 of 10

    My client feels the built in page numbering system is not clear. He would like to see what page number you are on in relation to the total number of pages for the product category we are on. Nothing more for this display.
    It is also possible to modify the page change/display code so that only 1 page # is displayed with the prev/next options available. Under configuration->Maximum Values, you can change the Prev/Next Navigation Page Links to a value of 1 and will always be provided a next until the end, or a prev until the beginning, of course wouldn't have the total displayed without additional coding.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Adding page numbers to multiple products view.

    OK, so trying to put the page number like I want and still keep the other page numbers (built in pagination) seems like it's going to need a major overhaul. Since not many are responding and the response that were received looks like it's going to be very diffucult, how hard would it be to turn the built in pagination to this:
    (left arrow) Page 3 of 10 (Right Arrow). Would this be much easier? I think maybe I need to pursue this path if I have to.

  7. #7
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Adding page numbers to multiple products view.

    Quote Originally Posted by sports guy View Post
    OK, so trying to put the page number like I want and still keep the other page numbers (built in pagination) seems like it's going to need a major overhaul. Since not many are responding and the response that were received looks like it's going to be very diffucult, how hard would it be to turn the built in pagination to this:
    (left arrow) Page 3 of 10 (Right Arrow). Would this be much easier? I think maybe I need to pursue this path if I have to.
    Haven't done this in some time but for the product listing page, in:
    /includes/templates/YOUR_TEMPLATE_NAME/templates/tpl_modules_product_listing.php

    ADD:
    PHP Code:
    <?php echo 'Displaying Page ' $listing_split->current_page_number ' of ' $listing_split->number_of_pages '<br />'?>
    That should Display:
    Displaying Page # of #

    To replace the stock pagination you will need to re-code the /includes/classes/split_page_results.php, I do not have time at the moment but above should give you direction.

  8. #8
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding page numbers to multiple products view.

    Quote Originally Posted by sports guy View Post
    OK, so trying to put the page number like I want and still keep the other page numbers (built in pagination) seems like it's going to need a major overhaul. Since not many are responding and the response that were received looks like it's going to be very diffucult, how hard would it be to turn the built in pagination to this:
    (left arrow) Page 3 of 10 (Right Arrow). Would this be much easier? I think maybe I need to pursue this path if I have to.
    So, like I said, relatively easy... In tpl_modules_product_listing.php, I added the following and now have Page X of Y (Insert page numbers for each):

    Code:
    <div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo 'Page ' . $listing_split->current_page_number . ' of ' . $listing_split->number_of_pages; ?></div>  
    <br class="clearBoth" />
    The use of hard coded English is incorrect; however, it represents the resolution... The div id= and/or class could/should be changed to something that can be positioned as necessary although if the Prev/Next section is moved, the above will move with it.

    If placed as this: then the two page representations are above one another:
    Code:
    <div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
    <div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo 'Page ' . $listing_split->current_page_number . ' of ' . $listing_split->number_of_pages; ?></div>  
    <br class="clearBoth" />
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  9. #9
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Adding page numbers to multiple products view.

    Thank you both, I appreciate your time. In a few months I think he will look for a PHP developer to build this custom. I just told him it was out of my comfort zone.

  10. #10
    Join Date
    Jul 2012
    Posts
    16,817
    Plugin Contributions
    17

    Default Re: Adding page numbers to multiple products view.

    Quote Originally Posted by sports guy View Post
    Thank you both, I appreciate your time. In a few months I think he will look for a PHP developer to build this custom. I just told him it was out of my comfort zone.
    That's a shame, seems that rbarbour got it posted first, a straight out answer was given within a few minutes of the latest post and sure, might have used a little zenning, would have worked just fine as is.

    Ah well, at least someone else now has the code available to add a "Page X of Y" to their site.
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

 

 

Similar Threads

  1. v139h Adding Page Numbers to Bottom
    By traytray in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 6 Nov 2012, 10:07 AM
  2. Replies: 3
    Last Post: 16 Jun 2010, 06:08 AM
  3. Multiple thumbnail view on product listing page
    By tat1973 in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 23 Nov 2007, 02:21 AM
  4. View Cart After Adding Products
    By ahuacatlan in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 8 Sep 2007, 03:41 AM
  5. Adding stock numbers to products
    By Catharina in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 7 Apr 2007, 01:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg