We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6513
    • 28 Posts
    Hello all,
    I am trying to display a link at the bottom of each page that leads to the next page. These are all separate documents, not using pagination. I have a snippet set up that gets the current document id and name, but am having issues advancing it to the next document in my DB. This information is contained in a separate table in my DB (separate from the modx tables).

    snippet as it is now:
    $output = '';
    $sql = $modx->db->query("SELECT co_name,doc_id FROM main WHERE co_name='$company' LIMIT 0,2");//tried setting a lIMIT even though I knew it wouldn't work
    $resultArray = $modx->db->makeArray( $sql );
    foreach($resultArray as $item){
    	$params['doc_id']=$item['doc_id'];
    	$params['co_name'] = $item['co_name'];
    	$output.=$modx->parseChunk('nextCompanyTpl', $params, '[+', '+]');
    	}
    return $output;
    


    this brings me the current document’s id and name but I cannot figure where to start to get the next document. All of these pages describe a company, each company is in the DB, but not in alphabetical order. So I can use ORDER BY, so I need to figure out how to start the query with the current page (using a TV called [*company*]) that is passed to the snippet call and get the next alphabetical company.

    I hope that makes sense. This is probably more of a MySQL question, if so please let me know.

    Thanx,
    Daniel
      • 26931
      • 2,314 Posts
      I am trying to display a link at the bottom of each page that leads to the next page
      have a look at the PrevJumpNext Snippet http://modxcms.com/forums/index.php?topic=5925.0 or Navigator http://modxcms.com/extras/package/314
        • 6513
        • 28 Posts
        Thanx! I think PrevJumpNext is what I need smiley