We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36516
    • 179 Posts
    Hi guys. I'm trying to create page links for a kind of blog where I need the page number to be visible but start from the last page. I've been looking at the getPage code and I'm not convinced it's possible, either to get it to start from the last page, or to use a URL parameter to jump to the 'last' page, or similar.

    I could really do with some advice. The options here seem so limited I'm left wondering if I'm just approaching it the wrong way. Obviously I can reverse the order of the pages so it starts with the last entry, as is normal I suppose, but I need the page number to be > 1.

    I'm starting to think I'm going to have to hack about with the getPage snippet to listen for a custom URL parameter just so I can force the 'page' number to the end. It doesn't look like it'll be hard to do, but isn't it a bit ridiculous?
      • 3749
      • 24,544 Posts
      Have you tried using something like &page=`12` in the snippet tag?

      If that doesn't work, it's an ugly hack, but if you know the page number of the last page, you can just change the 1 at the end of this code (around line 10 of the snippet to that page number:

      if ($properties['page'] === null) {
          $properties['page'] = (isset($_REQUEST[$properties['pageVarKey']]) && ($page = intval($_REQUEST[$properties['pageVarKey']]))) ? $page : 1;
      }


      If you don't know how many pages there will be, it gets more complicated, because the page count isn't calculated until later in the code. I think I see a way to do it, but I'm not sure it will work.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 36516
        • 179 Posts
        If I have to modify the getPage snippet (and can do everything I need without the need to change any of the includes), I suppose the best thing to do is duplicate the snippet and create a new one with a different name for my specific purposes. That way I can avoid future getPage updates ruining everything. I haven't done this before, so I'm going to need to work out how default properties work. I presume I need to configure the defaults to be the same/similar to those that come with getPage, unless those are duplicated with the snippet.
        • Order the result backwards and use the default pagination is not an option?
            • 36516
            • 179 Posts
            Unfortunately not. It's a story kind of thing, and when people come to the site to read it it needs to show that they're on the latest page, and allow them to page backwards, not forwards, from the latest/last page. Page 1 will always be the cover page. It's frustrating that this basic requirement isn't easily achieved, but I suppose it takes an unusual case to reveal a potential need. Perhaps I should go through the proper channels to have getPage upgraded with paging keywords like 'first', 'last', etc.
              • 22840
              • 1,572 Posts
              Quote from: davidsmith at Oct 13, 2015, 08:05 PM
              Unfortunately not. It's a story kind of thing, and when people come to the site to read it it needs to show that they're on the latest page, and allow them to page backwards, not forwards, from the latest/last page. Page 1 will always be the cover page. It's frustrating that this basic requirement isn't easily achieved, but I suppose it takes an unusual case to reveal a potential need. Perhaps I should go through the proper channels to have getPage upgraded with paging keywords like 'first', 'last', etc.
              So when a new person comes to the site you wan't to show them page 17 of the story in instead of the start of the story ? ( does that not spoil it for all new comers ?

              Personally I would re think how you are presenting this to the user and perhaps do it so that they land on the first page with a link at the top to jump to latest ( of something like that ) for the regular readers and that link takes them to the latest story page.

              You also say:

              Page 1 will always be the cover page

              thats easy with the standard ordering, but whats the point if people never see it after page 2 is published ?

              How exactly is this structured in the tree and what are you displaying with get page ? [ed. note: paulp last edited this post 8 years, 5 months ago.]
                • 20413
                • 2,877 Posts
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 36516
                  • 179 Posts
                  I'm using pagination with first/last buttons. I need only 'previous', 'next' and the current page number in the middle. In fact, to achieve that I had to hide some additional page links with CSS because getPage doesn't honour the parameter that limits the number of page links. If you enter a number less than three you always get the current, next and previous numbers (three in total) in addition to next, prev, first and last.

                  Anyway, I'm building this to spec. It's not mine. It's actually a webcomic, and as such it's convention that visitors always come in at the latest page. I presume the story will be ongoing, like a soap, and so starting from the beginning isn't as helpful, or as normal as it seems like it should be.

                  So while I appreciate your feedback, and opinion, unfortunately there's no room for negotiation. When there are hundreds of pages it'll make more sense to jump to the latest and work out where you left off. In any case I kinda agree, if you start from the beginning you are only a click of "LATEST" from the end. But the same is true of getting back to the start and when there's a lot of pages people are less likely to be starting from the beginning. Plus showing the last page has the added benefit of showing at first glance how much content there is to be viewed, without the need to show the total number of pages separately.
                    • 36516
                    • 179 Posts
                    @mrhaw: Could you possibly elaborate on your suggestion? I'm not sure I follow entirely, but it sounds promising. I'd like to avoid duplicating an existing snippet if I can.
                      • 20413
                      • 2,877 Posts
                      Quote from: davidsmith at Oct 13, 2015, 08:52 PM
                      @mrhaw: Could you possibly elaborate on your suggestion? I'm not sure I follow entirely, but it sounds promising. I'd like to avoid duplicating an existing snippet if I can.

                      I would write a custom snippet that loads getPage, count the totals, assign each item with a number in reversed order. Customizing the getPage snippet might be easier. It's just a thought! smiley
                        @hawproductions | http://mrhaw.com/

                        Infograph: MODX Advanced Install in 7 steps:
                        http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                        Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                        http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower