We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44546
    • 7 Posts
    Hi everyone, I have a blog set up in modx revolution using the articles addon, but I cannot find documentation on how to disable and/or configure certain parts of the pagination. My current call for the pagination looks like this:

    [[!+page.nav:notempty=`<nav>[[!+page.nav]]</nav>`]]

    I'm not using [[+paging]] because it wraps the navigation in an <ul>, and I'd rather wrap it in a <nav>.

    Now, what I'm trying to do is these two things

    1. The default pagination shows: First - Next - 1 - 2 - 3 - Previous - Last for the pagination controls. I would like to leave First and Last out.
    2. By default the Next and Last links disappear if there is no next or last page. However, I'd rather make them inactive in such a case, but still display them.

    My question is

    I'm hoping someone knows how to do this. I'm suspecting it has something to do with getpages or getresources, but have no idea how to actually do this. Anyone?

    This question has been answered by john-siggran. See the first response.

      • 21078
      • 77 Posts
      Hi John,

      did you try the getPage add-on already on retrieving and styling your pagination? A good start for this is the official documentation which includes some examples too:

      http://rtfm.modx.com/display/ADDON/getPage
        L.net Web Solutions
        Professional webdesign and development with MODX and WordPress.
        • 44546
        • 7 Posts
        Quote from: Nebulous at Jul 22, 2013, 05:29 AM
        Hi John,

        did you try the getPage add-on already on retrieving and styling your pagination? A good start for this is the official documentation which includes some examples too:

        http://rtfm.modx.com/display/ADDON/getPage

        Hi Chris,

        Yes I did, it got me a little bit further. I've added the following listing parameters to the getPage call, to remove the [[+first]] and [[+last]] template from the pagination, and insert a static "back to top" link:

        &pageNavOuterTpl=`[[+prev]]<a href="#header">Back to top</a>[[+next]]`


        However, one thing still eludes me: by default the previous and next links disappear if there is no previous or next page, which makes sense. However I'd rather display a placeholder, styled as inactive with css. That way the pagination always looks the same, but inactive parts are grayed out.

        So what I'm trying to do is set an :ifempty value for [[+prev]] and [[+next]], and I still haven't figured out how to do that.

        I've tried using &pagePrevTpl:ifempty and &pageNextTpl:ifempty, and have them insert the html when they're empty, but for whatever reason that doesn't work. Maybe because getPage somehow supersedes that?

        I've also tried to use the filters like so: &pageNavOuterTpl=`[[+prev:ifempty=`empty`]]<a href="#header">Back to top</a>[[+next:ifempty=`empty`]]`, it returns the ifempty value, even in cases where it shouldn't be empty (i.e. there is a next or previous page to be displayed). Maybe this has something to do with the parsing order, and getPage only fills in the empty spaces after the :ifempty check?

        Do you know how to do this?

        [ed. note: john-siggran last edited this post 13 years, 2 months ago.]
          • 21078
          • 77 Posts
          Hm, have you tried [[+prev:default=`your empty code`]] and [[+next:default=`your empty code`]]?
            L.net Web Solutions
            Professional webdesign and development with MODX and WordPress.
            • 44546
            • 7 Posts
            Quote from: Nebulous at Jul 22, 2013, 06:16 AM
            Hm, have you tried [[+prev:default=`your empty code`]] and [[+next:default=`your empty code`]]?

            Hi Chris,

            Yes I have, weird thing is that if I do that it always displays the :default value, even in cases where it shouldn't (just like with the :ifempty option). Do you know why that is?

            By the way, I'm entering this in the "Advanced settings > General > Other Listing Parameters" field. So with your code it looks like this:

            &pageNavOuterTpl=`[[+prev:default=`your empty code`]]<a href="#header" title="Back to the top"><span>Back to top</span></a>[[+next:default=`your empty code`]]`


            But as said, it does not work as expected, and always displays the default value. Should I maybe try doing this in the PagePrevTpl and PageNextTpl areas? [ed. note: john-siggran last edited this post 13 years, 2 months ago.]
              • 21078
              • 77 Posts
              Hey John,

              you're right – very strange ... "default" overwrites every output like "empty" too. I tried some more variations, also with the "If" snippet but it just won't work as expected. After taking a look at the snippet code itself I think this needs a little change in order to return empty placeholders for prev/next:

              https://github.com/opengeek/getPage/blob/master/core/components/getpage/include.getpage.php

              But this may goes a bit too far. Instead you could give the siblingNav snippet a try?!

              http://rtfm.modx.com/display/ADDON/SiblingNav

              Or does anyone else has an idea?
                L.net Web Solutions
                Professional webdesign and development with MODX and WordPress.
                • 44546
                • 7 Posts
                Quote from: Nebulous at Jul 22, 2013, 07:37 AM
                Hey John,

                you're right – very strange ... "default" overwrites every output like "empty" too. I tried some more variations, also with the "If" snippet but it just won't work as expected. After taking a look at the snippet code itself I think this needs a little change in order to return empty placeholders for prev/next:

                https://github.com/opengeek/getPage/blob/master/core/components/getpage/include.getpage.php

                But this may goes a bit too far. Instead you could give the siblingNav snippet a try?!

                http://rtfm.modx.com/display/ADDON/SiblingNav

                Or does anyone else has an idea?

                Hmm.. I've tried siblingnav, but cannot really get it to work with the syntax as suggested on the page you linked to. Is there no way to somehow use the default pagination with articles for this? Looks like these lines in include.getpage.php are what causes the trouble:

                if (!empty($pagePrevTpl) && ($page - 1) >= 1) {
                    $nav['prev'] = getpage_makeUrl($modx, $properties, $page - 1, $pagePrevTpl);
                }
                
                // and
                
                if (!empty($pageNextTpl) && ($page + 1) <= $pageCount) {
                    $nav['next'] = getpage_makeUrl($modx, $properties, $page + 1, $pageNextTpl);
                }


                They'll only return the next and prev items if there is a next and previous page. Now what I'm looking for is something like:

                if (!empty($pagePrevTpl)) {
                	if (($page - 1) >= 1) {
                		$nav['prev'] = getpage_makeUrl($modx, $properties, $page - 1, $pagePrevTpl);
                	} else {
                		$nav['prev'] = x // where x = the default value for prev (the one set with :default)
                	}
                }


                Is there a way to modify this without the changes getting overwritten on an upgrade? With a property set or something? A simple else or elseif would do the trick, but that would be gone after an upgrade. It surprises me that I am the first who is trying to do this. Seems to me that it could be useful to have the :default-functionality work for the prev and next items. Anyone have any ideas on the best way to approach this? [ed. note: john-siggran last edited this post 13 years, 2 months ago.]
                  • 44546
                  • 7 Posts
                  Anyone? I know this isn't f*cking stack overflow, but a response would be nice. How come noone is able to get one simple f*cking :notempty filter to f*cking work?

                  GODDAMMIT! [ed. note: john-siggran last edited this post 13 years, 2 months ago.]
                    • 37105
                    • 194 Posts
                    Please keep your behaviour at normal level!
                      Codeplaza Webdesign: for professional websites at low cost
                      • 44546
                      • 7 Posts
                      Quote from: donquicky at Jul 25, 2013, 06:07 AM
                      Please keep your behaviour at normal level!

                      Well at least that's a response. Now if only this forum was as fast with responding to questions.

                      I basically have to resort to javascript or some other crappy solution because this cms can't handle one simple thing: just a simple placeholder that gets overwritten when there's content.