We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7231
    • 4,205 Posts
    gracedman: I see in the code that the isFolder field info is available. With this you could know if a document is a parent (isFolder) or not. So you could add an if statement in the logic and go to the sub (children) in this instance. I would need to think a bit more than I am able to right now to get into more details but I think that is the direction to look.

    isfolder - [0|1] Whether or not the document is a folder.

    First you need to get your self into the children level. But remember that you need to get back to the parent level as well and you have to be able to set a limit so that it doesn’t go all the way back to the home page (unless that is what you want).
      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

      Something is happening here, but you don't know what it is.
      Do you, Mr. Jones? - [bob dylan]
      • 7231
      • 4,205 Posts
      gracedman: Just curious, are you wanting to use <prev next> AND the jump menu or just one or the other? The reason I ask is that it is easy to do the jump part with wayfinder to create the jump menu.

      Regarding the prev/next links; how would you want it to behave when reaching a page with children? Should the next button go down into the children? But what if the reader wants to continue on the same level rather than going into a sub section?
        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

        Something is happening here, but you don&#39;t know what it is.
        Do you, Mr. Jones? - [bob dylan]
        • 11190
        • 109 Posts
        Hi, dev. I have already created a fly out table of contents for navigating the entire document using Wayfinder as you suggest. However, I’m trying to duplicate the book reading experience of turning the pages. It is very inconvenient to go back to the table of contents just to turn the page. That’s why I would like the Next/Prev links to be the equivalent of a page turn.

        My assumption (and it is an assumption) is that it is more natural to turn to the table of contents to go to the next section more than it is to go to the next page. Thus, if they want to go to the child (or uncle if they are at the last child of a parent!), I would like them to simply click on next. If they want to go back to the parent or to the beginning of another section, they can use the fly out table of contents. So, yes, the next button should go to the children if that would be the next natural page. Those are my thoughts. Thanks - John
          http://www.spiritualoutreach.com
          Making Christianity intelligible to secular society
          • 22851
          • 805 Posts
          Here’s a modified version of the PrevJumpNext snippet. I have attempted to modify the output so that it can be used in XHTML 1.0 Transitional (and probably Strict with very minor modifications, it at all) documents served as application/xhtml+xml. I haven’t tested it extensively, but it appears to work fine with the latest versions of Safari, Mozilla and Internet Explorer. The interface is the same as the original version. Only the output is different.

          <?php
          /**
           *
           * **************************
           * Snippet: PrevJumpNextXHTML
           * By: Jeroen Bosch modded by OncleBen31 and modified again by PMS
           * Date: Mar 2008
           * version: 0.3 (based on the PrevJumpNext v0.3)
           * **************************
           *
           * Function:
           * Generates buttons to navigate between document of a same directory. 
           * Very handy on top or bottom of each individual newspost/log item
           * Highly configurable. It can display :
           *  - 'Prev' and 'Next' button with or without document titles
           *  - 'first' and 'last' document.
           *  - 'Index' link to parent folder
           *  - a DropList to jump quickly to a document
           *
           * You can use a classic use of the snippet or use the paginate option
           * which allow you to use PlaceHolders to personnalise your navigation 
           * buttons :
           *  - [+PJN_first+] : the first document
           *  - [+PJN_prev+] : the previous document
           *  - [+PJN_jump+] : the droplist to jump to the selectionned document
           *  - [+PJN_index+] : the link to retern to the index page
           *  - [+PJN_next+] : the next document
           *  - [+PJN_last+] : the last document
           * 
           * There is many option which can allow you to sort the document, set 
           * the text to use with the element, etc ... :
           * - sortBy : Sort items by? 'menuindex' or 'id' or 'createdon', etc... (default createdon)
           * - sortHow : Sort items How? 'ASC' or 'DESC' (default ASC)
           * - displayTitle : how 'prev' and 'next' or display document titles (default true)
           * - displayFixed : Show 'first' and 'last' (default false)
           * - usePlaceHolder : Set at true to use PlaceHolder : [+PJN_first+] , [+PJN_prev+] , [+PJN_jump+] , [+PJN_index+] , [+PJN_next+] , [+PJN_index+]  (default false)
           * - useJump : Replace the Index link by the Jump dropList when NOT using the PlaceHolders (default false)
           * - indexDocumentID :Specifie the document to go using the link "index". (by default its is the parent ID)
           * - displayNoPrevNext : set to true to display a text when there is no Prev or no Next element (default false)
           * - noPrevNextText : Text to display if there is no Prev or no Next element :(default "-")
           * - indexText : Text to use with the link "index" (default "Index")
           * - jumpText : Text to use with the dropdown list (jump function) (default :"Please Select")
           * - firstText : Text to use with the link "First" (default "<< First")
           * - prevText : Text to use with the link "Prev" when $displayTitle is set to false (default "< Prev")
           * - nextText : Text to use with the link "Next" when $displayTitle is set to false (default "Next >")
           * - lastText : Text to use with the link "Last" (default "Last >>")
           *
           *
           * The output use <div> and <span> to allow you to CSS the buttons
           * 
           *
           * Enjoy and don't esitate to ask new features
           * Exemples :
           * 
           * [[PrevNext? sortBy=menuindex &sortHow=ASC &displayTitle=true]]
           * Or
           * [[PrevJumpNext_New? &sortBy=`pub_date` &usePlaceHolder=true &indexDocumentID=`84` &firstText=`Première` &lastText=`Dernière` &prevText=`Précédente` &nextText=`Suivante` &indexText=`Liste des News` &jumpText=`Accès rapide` &displayNoPrevNext=true &noPrevNextText=`C'est le bout`]]
           * with this place holder in the document [+PJN_first+] [+PJN_prev+] [+PJN_jump+] [+PJN_index+] [+PJN_next+] [+PJN_last+] 
           */
          
          /* TODO 
           - Limiter la longeur de la liste
           - Ajouter la phrase article n° X sur Total
           - Faire la traduction
           - Ajouter un préfix lors de l'utilisation des titres pour Prev et Next
          */
           
           
          # Settings
          
          # Sort items by? 'menuindex' or 'id' or 'createdon'
          if(!isset($sortBy))
          {
              $sortBy = 'createdon'; // default in NewsListing-snippet
          }
          
          # Sort items How? 'ASC' or 'DESC'
          if(!isset($sortHow))
          {
              $sortHow = 'ASC'; // default in NewsListing-snippet
          }
          
          # Show 'prev' and 'next' or display document titles?
          if(!isset($displayTitle))
          {
              $displayTitle = true;
          }
          
          # Show 'first' and 'last'
          if(!isset($displayFixed))
          {
              $displayFixed = false;
          }
          
          // Parameters added By OncleBen31
          
          # Set at true to use PlaceHolder : [+PJN_first+] , [+PJN_prev+] , [+PJN_jump+] , [+PJN_index+] , [+PJN_next+] , [+PJN_index+] 
          if(!isset($usePlaceHolder))
          {
             $usePlaceHolder = false;
          }
          
          # Replace the Index link by the Jump dropList when NOT using the PlaceHolders
          if(!isset($useJump))
          {
             $useJump=false;
          }
          
          # Specifie the document to go using the link "index". (by default its is the parent ID)
          if(!isset($indexDocumentID))
          {
             $indexDocumentID=$modx->documentObject['parent'];
          }
          
          # set to true to display a text when there is no Prev or no Next element
          if(!isset($displayNoPrevNext))
          {
             $displayNoPrevNext=false;
          }
          # Text to display if there is no Prev or no Next element
          if(!isset($noPrevNextText))
          {
             $noPrevNextText="-";
          }
          
          # Text to use with the link "index"
          if(!isset($indexText))
          {
             $indexText="Index";
          }
          
          # Text to use with the dropdown list jump function
          if(!isset($jumpText))
          {
             $jumpText="Please Select";
          }
          
          # Text to use with the link "First"
          if(!isset($firstText))
          {
             $firstText="<< First";
          }
          
          # Text to use with the link "Prev" when $displayTitle is set to false
          if(!isset($prevText))
          {
             $prevText="< Prev";
          }
          
          # Text to use with the link "Next" when $displayTitle is set to false
          if(!isset($nextText))
          {
             $nextText="Next >";
          }
          
          # Text to use with the link "Lastt"
          if(!isset($lastText))
          {
             $lastText="Last >>";
          }
          
          
          //
          // The code:
          //
          
          // Get the parent ID
          $parentid = $modx->documentObject['parent']; // maybe this solves it all, but I'm not sure.
          
          // (re)set the $id variable to the one of this document.
          $id = $modx->documentIdentifier;
          
          // select the other members in this folder -- See: NOTE 1
          $fields='id,pagetitle,isfolder'; // what fields do you want to know
          $children = $etomite->getActiveChildren($parentid, $sortBy, $sortHow, $fields);
          
          // the number of selected documents
          //$limit = $modx->recordCount($children);
          $limit = count($children);
          
          // set $y to zero
          $y = 1;
          
          // sorting the documents, giving them a sequential and searchable index
          foreach ($children as $child)
          {
              $my_array[$y] = $child;
              if ($my_array[$y]['id']==$id)
              {
                  $current=$y; // The current page has number $y in the array
              }
              $y++;
          }
          
          $prev = $current-1;
          $next = $current+1;
          
          // ### Construction oh the elements
          
          // First item
          $PJN_firsPlaceHolder =
             '<a href="[~'
             . $my_array[1]['id']
             . '~]">'
             . $firstText
             . '</a>';
          
          // Prev item
          if($prev > 0 && !$displayTitle )
          {
             $PJN_prevPlaceHolder =
                '<a href="[~'
                . $my_array[$prev]['id']
                . '~]">'
                . $prevText
                . '</a>';
          }
          elseif($prev > 0 && $displayTitle)
          {
             $PJN_prevPlaceHolder =
                '<a href="[~'
                . $my_array[$prev]['id']
                . '~]">'
                . $my_array[$prev]['pagetitle']
                . '</a>';
          }
          elseif($prev <= 0 && $displayNoPrevNext)
          {
             $PJN_prevPlaceHolder = $noPrevNextText;
          }
          
          // Jump item
          $PJN_jumpPlaceHolder =
             '<form action="" name="jump1" style="display:inline;">'
             . '<select name="myjumpbox" onchange="javascript:if (this.selectedIndex != 0) {var ops=this.getElementsByTagName(\'option\'); var url=ops[this.selectedIndex].getAttribute(\'value\'); if (url) {location.href=url;};}">'
             . '<option selected="selected">'
             . $jumpText
             . '</option>';
             
          foreach ($my_array as $my_page)
          {
            $PJN_jumpPlaceHolder .=
               '<option value="[~'
               . $my_page['id']
               . '~]" >'
               . $my_page['pagetitle']
               . '</option>';
          }
          $PJN_jumpPlaceHolder .= '</select></form>';
          
          // Index item
          $PJN_indexPlaceHolder =
             '<a href="[~'
             . $indexDocumentID
             . '~]">'
             . $indexText
             . '</a>';
          
          // Next item
          if($next <= $limit && !$displayTitle)
          {
             $PJN_nextPlaceHolder =
                '<a href="[~'
                . $my_array[$next]['id']
                . '~]">'
                . $nextText
                . '</a>';
          }
          elseif($next <= $limit && $displayTitle)
          {
             $PJN_nextPlaceHolder =
                '<a href="[~'
                . $my_array[$next]['id']
                . '~]">'
                . $my_array[$next]['pagetitle']
                . '</a>';
          }
          elseif($next > $limit && $displayNoPrevNext)
          {
             $PJN_nextPlaceHolder = $noPrevNextText;
          }
          
          // Last item   
          $PJN_lastPlaceHolder =
             '<a href="[~'
             . $my_array[$limit]['id']
             . '~]">'
             . $lastText
             . '</a>';
          
          // #### Output commputing modded by Oncleben31
          
          if (!$usePlaceHolder)
          {
          
             // Here starts the output
             $output = '';
             $output .= '<div class="PJN_Menu">';
             
             if($displayFixed)
             {
                $output .=
                   $PJN_firsPlaceHolder
                   . ' < ';
             } 
             
             $output .=
                $PJN_prevPlaceHolder
                . ' | ';
             
             if($useJump)
             {
                $output .=
                   $PJN_jumpPlaceHolder
                   . ' | ';
             }
             else
             {
                $output .=
                   $PJN_indexPlaceHolder
                   . ' | ';
             }
                
             $output .= $PJN_nextPlaceHolder;
             
             if($displayFixed)
             {
                $output .=
                   ' > '
                   . $PJN_lastPlaceHolder;
             } 
             
             $output .= '</div>';
             
             return $output;
          }
          else
          {
             
             // Set PlaceHolder
             $modx->setPlaceholder(
                'PJN_first'
                , '<span class="PJN_Menu"><span class="PJN_First">'
                   . $PJN_firsPlaceHolder
                   . '</span></span>'
                 );
             $modx->setPlaceholder(
                'PJN_prev'
                , '<span class="PJN_Menu"><span class="PJN_Prev">'
                   . $PJN_prevPlaceHolder
                   . '</span></span>'
                 );  
             $modx->setPlaceholder(
                'PJN_jump'
                , '<span class="PJN_Menu"><span class="PJN_Jump">'
                   . $PJN_jumpPlaceHolder
                   . '</span></span>'
                 );
             $modx->setPlaceholder(
                'PJN_index'
                , '<span class="PJN_Menu"><span class="PJN_Indext">'
                   . $PJN_indexPlaceHolder
                   . '</span></span>'
                );
             $modx->setPlaceholder(
                'PJN_next'
                , '<span class="PJN_Menu"><span class="PJN_Next">'
                   . $PJN_nextPlaceHolder
                   . '</span></span>'
                );
             $modx->setPlaceholder(
                'PJN_last'
                , '<span class="PJN_Menu"><span class="PJN_Last">'
                   . $PJN_lastPlaceHolder
                   . '</span></span>'
                );
             
          }
          ?>
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
            • 17705
            • 501 Posts
            interesting PMS..... do you have implemented it somewhere?
            just to see how it works / looks
              • 22851
              • 805 Posts
              Hi Luuuciano.

              It should function in exactly the same way as PrevJumpNext 0.3 does - so you can configure it to use a drop down box, or links that jump to the next, previous, first and last sibling documents etc. How it looks depends on how you choose to style it. The main difference between the two versions is that PrevJumpNext 0.3 wont work on an XHTML page, whereas PrevJumpNextXHTML 0.3 does. I don’t have a version on a page that’s online at the moment though, but I’ve tried to attach a screenshot of a test implementation using a drop-down.
                YAMS: Yet Another Multilingual Solution for MODx
                YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
                • 11190
                • 109 Posts
                Hello, all. I have come across another pressing need to be able to have Next go to the first child if it exists and Prev to go to the next parent sibling if there is no sibling at the same level, i.e, I need to have them follow the pages in a hierarchical document. I posted before and received some very helpful advice from dev_cw:

                gracedman: I see in the code that the isFolder field info is available. With this you could know if a document is a parent (isFolder) or not. So you could add an if statement in the logic and go to the sub (children) in this instance. I would need to think a bit more than I am able to right now to get into more details but I think that is the direction to look.

                Quote
                isfolder - [0|1] Whether or not the document is a folder.

                First you need to get your self into the children level. But remember that you need to get back to the parent level as well and you have to be able to set a limit so that it doesn’t go all the way back to the home page (unless that is what you want).

                Has anyone had a chance to think about this further? I would love to learn PHP in order to make this change but alas, other work presses and this particular site is a volunteer project. Worse comes to worse, I’ll see if I can hack my way through but I hate making changes to code I don’t understand! Thanks - John
                  http://www.spiritualoutreach.com
                  Making Christianity intelligible to secular society
                  • 6649
                  • 25 Posts
                  Hey everyone

                  Quick question concerning PJN snippet. I want to maintain the buttons I have created and place a holder into the href tag in the template to create forward and back buttons.


                  • Can someone tell me how I would write the snippet based on the order they appear in menu index?
                  • Is it possible to just place a placeholder into the href tag?

                  Thanks very much guys,

                  Dave01
                    • 3004
                    • 21 Posts
                    I’ve released a new version of PrevJumpNext (http://modxcms.com/PrevJumpNext-0.4-2124.html) with the following new parameters:

                    - exclude : Array : Comma-separated list of document IDs to exclude from navigation (default [empty])
                    - separator : String : Inserted between items (default " | ");
                    - displayIndex : Boolean: display index menu item (default true);
                    - firstSymbol : String : Prefixed to "First" menu item (default [empty]);
                    - prevSymbol : String : Prefixed to "Previous" menu item (default [empty]);
                    - nextSymbol : String : Suffixed to "Next" menu item (default [empty]);
                    - lastSymbol : String : Prefixed to "Last" menu item (default [empty]);
                    - displayTotal : Boolean : Show "Showing article X of Y" item (default true);
                    - recordTypeName : String : Name of records type for "Total" item.  E.g. (if = "article") "Showing article 3 of 25" (default "article");
                    - includeFolders : Boolean : include folder documents in the menu (default true);
                    - maxTitleChars : Int : Truncate document titles to this number of characters (default 0 [=display entire title]

                    I also revised the logic for when to show the "first" and "last" items, updated the instructions, and updated the html output. Please let me know if you run into any problems so I can fix them.

                    -Aaron
                      • 7231
                      • 4,205 Posts
                      That is a very nice update, thanks. I have not used this snippet in a while but I will look forward to testing these new features.

                      includeFolders : Boolean : include folder documents in the menu (default true);
                      Will the menu now drill down into folders including the children in the menu? I have seen a request for this feature before.
                        [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                        Something is happening here, but you don&#39;t know what it is.
                        Do you, Mr. Jones? - [bob dylan]