We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20191
    • 7 Posts
    Hi all,

    Is it possible to add links to navigate through blog entries? I would like to modify the chunk that comes out the box named "FormBlogComments" from;

    <p style="margin-top: 1em;font-weight:bold">Enter your comments in the space below (registered site users only):</p>

    [!UserComments? &canpost=`Registered Users, Site Admins` &makefolder=`0` &postcss=`comment` &titlecss=`commentTitle` &numbercss=`commentNum` &altrowcss=`commentAlt` &authorcss=`commentAuthor` &ownercss=`commentMe` &sortorder=`0`!]

    to;


    <p style="margin-top: 1em;font-weight:bold">Enter your comments in the space below (registered site users only):</p>

    [!UserComments? &canpost=`Registered Users, Site Admins` &makefolder=`0` &postcss=`comment` &titlecss=`commentTitle` &numbercss=`commentNum` &altrowcss=`commentAlt` &authorcss=`commentAuthor` &ownercss=`commentMe` &sortorder=`0`!]
    <p> Next Article : Previous Article (with some logic to check if there is a now/next link to present to user?)

    New to MODx and PHP!!

    TIA
      • 20191
      • 7 Posts
      DOH!

      Just noticed that NewsListing does this for me!! Getting the hang of this great CMS now!!

      But - how can you isolate via the snippet to view just from ONE folder, and said articles that are contained in that folder ONLY?

      Using this code;

      [!NewsListing? &amp;startID=`42` &amp;summarize=`3` &amp;paginate=`1` &amp;alwaysshow=`1`!]

      Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles
      [+previous+] [+pages+] [+next+] <div>&nbsp;</div>

      Where the folder i’ve called News has a value of 42 in the () next to the folder icon in the Manager?
        • 18397
        • 3,250 Posts
        Is it possible to add links to navigate through blog entries?

        There are many snippets that do that including this one:

        //
        // **************************
        // Snippet: PrevNext
        // By: Jeroen Bosch
        // Date: februari 2005
        // version: 0.9
        // **************************
        //
        // Function:
        // Generates a simple previous and next button. very
        // handy on top or bottom of each individual newspost/log item
        // Highly configurable. It can display document titles
        // and add 'first' and 'last' to the options.
        //
        // You can set every option with the snippet call.
        // example:
        
        // [[PrevNext?sortBy=menuindex&sortHow=ASC&displayTitle=true]]
        
        
        # 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;
        }
        
        // 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;
        
        // Here starts the output
        $output = "";
        $output .= "<div class='PrevNextMenu'><div>";
        
        if($displayFixed==true) {
            $output .= "< <a href='[~".$my_array[1]['id']."~]'>first</a> ‌ ";
        } else {
            $output .= "< ";
        }
        
        if($prev > 0 && $displayTitle==false){
            $output .= " <a href='[~".$my_array[$prev]['id']."~]'>prev</a> ";
        } elseif($prev > 0 && $displayTitle==true) {
            $output .= " <a href='[~".$my_array[$prev]['id']."~]'>".$my_array[$prev]['pagetitle']."</a> ";
        }
        
        $output .= "‌ <a href='[~".$parentid."~]'> index </a> ‌";
        
        if($next <= $limit && $displayTitle==false){
            $output .= " <a href='[~".$my_array[$next]['id']."~]'>next</a> ";
        } elseif($next <= $limit && $displayTitle==true) {
            $output .=" <a href='[~".$my_array[$next]['id']."~]'>".$my_array[$next]['pagetitle']."</a> ";
        }
        
        if($displayFixed==true) {
            $output .= " ‌ <a href='[~".$my_array[$limit]['id']."~]'>last</a> >";
        } else {
            $output .= " >";
        }
        
        $output .= "</div></div><br />";
        $output .= "";
        
        return $output;
        
          • 20191
          • 7 Posts
          Mark,

          Thank you very much for the reply and snippet - that works a treat for pagination of the articles.

          Except calling it this way;

          [[PrevNext?displayTitle=false&displayFixed=true]]

          Is still showing the document titles and not just prev/next?

          Also this is driving me mad still,as I am still wondering how you can via the NewsListing snippet isolate to read from ONE folder, and said articles that are contained in that folder ONLY?

          Every call I make using the NewsListing snippet seems to call all folders that came with the default install of Modx.

          TIA.
            • 18397
            • 3,250 Posts
            &startID=`idoffolderwithchildren`
              • 20191
              • 7 Posts
              Mark,

              Thanks very much for all your help.

              Works like a charm now smiley
                • 22221
                • 283 Posts
                I’ve made some modification to the PrevNext snippet to replace the index link by a dropdown list to the other document of the folder. I call it PrevJumpNext

                I hope this can help someone. I think it can be improved by option to add the parent link in the droptdown list or to use a CCS dropdown replacing the form one.

                //
                // **************************
                // Snippet: PrevJumpNext
                // By: Jeroen Bosch moded by OncleBen31
                // Date: februari 2005
                // version: 0.9
                // **************************
                //
                // Function:
                // Generates a simple previous and next button. very
                // handy on top or bottom of each individual newspost/log item
                // Highly configurable. It can display document titles
                // and add 'first' and 'last' to the options.
                //
                // You can set every option with the snippet call.
                // example:
                
                // [[PrevNext?sortBy=menuindex&sortHow=ASC&displayTitle=true]]
                
                
                # 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;
                }
                
                // 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;
                
                // Here starts the output
                $output = "";
                $output .= "<div class='PrevNextMenu'><div>";
                
                if($displayFixed==true) {
                    $output .= "< <a href='[~".$my_array[1]['id']."~]'>first</a> ‌ ";
                } else {
                    $output .= "< ";
                }
                
                if($prev > 0 && $displayTitle==false){
                    $output .= " <a href='[~".$my_array[$prev]['id']."~]'>prev</a> ";
                } elseif($prev > 0 && $displayTitle==true) {
                    $output .= " <a href='[~".$my_array[$prev]['id']."~]'>".$my_array[$prev]['pagetitle']."</a> ";
                }
                
                $output .= '‌ <form action="" name="jump1" style="display:inline;">
                <select name="myjumpbox"
                 OnChange="location.href=jump1.myjumpbox.options[selectedIndex].value">
                     <option selected>Please Select...';
                foreach ($my_array as $my_page) {
                //      $output .= '    <option value="'[~'.$my_page['id'].'~]">'.$my_page['title'];
                     $output .= '    <option value="[~'.$my_page['id'].'~]">'.$my_page['pagetitle'];
                
                }
                $output .= '</select></form> ‌';
                
                if($next <= $limit && $displayTitle==false){
                    $output .= " <a href='[~".$my_array[$next]['id']."~]'>next</a> ";
                } elseif($next <= $limit && $displayTitle==true) {
                    $output .=" <a href='[~".$my_array[$next]['id']."~]'>".$my_array[$next]['pagetitle']."</a> ";
                }
                
                if($displayFixed==true) {
                    $output .= " ‌ <a href='[~".$my_array[$limit]['id']."~]'>last</a> >";
                } else {
                    $output .= " >";
                }
                
                $output .= "</div></div><br />";
                $output .= "";
                
                return $output;
                  • 18397
                  • 3,250 Posts
                  MARKSVIRTUALDESK Reply #8, 18 years ago
                  Very cool! Can you please put this new snippet in its own thread and make the snippet a .txt download? Thanks!
                    • 22221
                    • 283 Posts
                    I want to do some modification, like using placeholder. I will post it when I achieved it.
                      • 22221
                      • 283 Posts
                      I’ve created a new topic dedicated to PrevJumpNext snippet :
                      http://modxcms.com/forums/index.php/topic,4300.msg31245.html#msg31245