We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51315
    • 67 Posts
    Does anyone have ever had this issue?
    You are using pdoNeighbors for a Prev/Next navigation.
    You got only one resource inside a container.
    So there is no previous nor next resource to go to.
    But pdoNeighbors shows the Prev button anyway, meaning that the Prev button links to the same page you are visiting.

    Which is the best way to simply hide the button if you only got 1 page and there are not 2+ resources to navigate through?
    • Haven't used it, but since pdoNeighbors can use the same parameters as pdoTools, maybe an output filter in a chunk to specify which tpl would work with totalVar placeholder?

      [[[[+total:is=`1`:then=`$tplWithoutPrev`:else=`$tplWithPrev`]]]]

      ^^ untested ^^
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 51315
        • 67 Posts
        Thanks Frogabog.
        I tried to insert

        [[+total:is=`1`:then=`nothing`:else=`<span class="link-prev"><a href="[[+link]]">← Previous</a></span>`]]


        in the tplPrev chunck but nothing happened. [ed. note: fredela last edited this post 8 years ago.]
        • Likely because "nothing" is... nothing. Make two chunks. One will have the markup for only one button, the other will have markup for two buttons.
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 51315
            • 67 Posts
            Actually it should just return "nothing", right?

            Tried this:

            [[pdoNeighbors?
                &sortby=`publishedon`
                &sortdir=`asc`
                &tplPrev=`[[+total:is=`1`:then=`tplPrev_empty`:else=`tplPrev`]]`
                &tplUp=`tplUp`
                &tplNext=`tplNext`
            ]]


            Same result.
            I only use pdoMenu so I am not a pdo expert.
            I quickly checked the documentation.
            Every pdo property should work with pdoNeighbors.
            Anyway, I did not find
            total
            in the general pdo properties list.
            Do you have a link?
              • 32507
              • 142 Posts
              mtalvenheimo Reply #6, 8 years ago
              What if write custom snippet which hides/strips pdoNeighbor if Parent has only one children?
              Or use &resources parameter to call snippet to subtract all resources without siblings?

              &resources=`[[snippetHere]]`

              [ed. note: wintertribe last edited this post 8 years ago.]
                • 51315
                • 67 Posts
                Hi mtalvenheimo, thanks.
                I am not good at php coding.
                Any idea about how to write that?
                  • 32507
                  • 142 Posts
                  mtalvenheimo Reply #8, 8 years ago
                  Unfortunately no fast solution. I'm a bit slow google>copy>paste coder myself too smiley

                  Maybe this will help?

                  https://forums.modx.com/thread/70700/how-do-i-get-all-siblings

                  or this

                  https://gist.github.com/pepebe/2431823
                    • 32507
                    • 142 Posts
                    mtalvenheimo Reply #9, 8 years ago
                    Try this?

                    [[pdoNeighbors? 
                    &resources=`[[stripLoners]]`
                    ]]


                    stripLoners snippet:

                    <?php
                    $id = $modx->resource->get('id');
                    $parent = $modx->resource->getOne('Parent');
                    $children = $parent->getMany('Children');
                    
                    if (count($children) == 1){
                        $output = '-' . $id;
                    } ;
                    
                    return $output;


                    EDIT

                    By the way. By default pdoNeighbors is not showing in resources without siblings?
                    For me it's working this way? [ed. note: wintertribe last edited this post 8 years ago.]
                      • 51315
                      • 67 Posts
                      Quote from: wintertribe at Apr 29, 2016, 10:01 AM

                      EDIT

                      By the way. By default pdoNeighbors is not showing in resources without siblings?
                      For me it's working this way?

                      You mean that pdoNeighbors by default should not show prev/next buttons if the parent contains only one resource?