Around line 176, you need to change:
I’m having the same problem on my side, is there a solution for this?
Would be grateful !
Quote from: lx at Sep 06, 2008, 03:44 PM
Hello,
Please advice me. In total pages I get always one page more that there are in my folder.
So If there are 5 documents in my folder I get 6 as a total pages, when i have 6 documents in my container I get 7 as total pages.
Please advice me what can be the problem.
I use PJN 0.4 ver with a simplest call [!PrevJumpNext!]
regards
lx
Thanks,
XeyefeX
$limit = $y;
$limit = $y-1;

labasus.
I am not sure what you are trying to do, but if you are interested in prev and next, but not interested in jump you could try my snippet, Navigator. It’s fully templatable and has options for excluding unpublished and non-showinmenu documents. About 100 people have downloaded it, but I have had no reports of bugs. I assume therefore that either no-one has actually used it or it’s working fine.
Oh yeah... It will also recurse up and down the document tree too, showing children and parents, not just siblings.
<?php
/*
* **************************
* Snippet: PrevJumpNext
* By: Jeroen Bosch modded by OncleBen31 modded by Aaron Heinrich
* Modified for version 0.5 by D Russell Wagner (drwagner13), August 2009
* Date: May 2006 - August 2009
* version: 0.5 (based on the PrevJumpNext v0.4)
* **************************
*
******Version 0.5 changes*******
*
* the displayTotal parameter now returns the correct number of documents
*
* PNJ now accepts the following new parameters:
*
* &displayWhat: to allow showing text other than the page title, such as the longtitle or menutitle
*
* As a step toward making this snippet fully templatable, the output when using the "usePlaceHolder" option
* now includes the following placeholders:
* - [+PJN_firstText+] : the first document's link text
* - [+PJN_firstID+] : the first document's ID * - [+PJN_prevText+] : the previous document's link text
* - [+PJN_prevID+] : the previous document's ID
* - [+PJN_indexText+] : the text to use for the index page link
* - [+PJN_indexID+] : the index page ID
* - [+PJN_nextText+] : the next document's link text
* - [+PJN_nextID+] : the next document's ID
* - [+PJN_lastText+] : the last document's link text
* - [+PJN_lastID+] : the last document's ID
* - [+PJN_currentRecord+] : the current document's index value in the list
* - [+PJN_totalRecords+] : the total number of documents in the list
*
* using the above placeholders, links can be built in a templated fashion:
* <a href="[~[+PJN_firstID+]~]">[+PJN_firstText+]</a>
* Note this is equivalent to the standard output, as given below, but the following is not:
* <tr><a href="[~[+PJN_firstID+]~]">FIRST</a></tr>
* <tr>[+PJN_firstText+]</a></tr>
*
* you can use the record numbers to make statements like "Showing record x of y."
*
* DESCRIPTION
*
* Generates links to navigate between documents in a directory.
* Highly configurable. It can display :
* - 'Showing article x of x'
* - 'Prev' and 'Next' links with or without document titles
* - 'First' and 'Last' links.
* - 'Index' link to parent folder
* - A select to jump quickly to a document
*
* Can output links or generate the following placeholders:
* the following placeholders output complete links to the referenced documents
* - [+PJN_first+] : a link to the first document
* - [+PJN_prev+] : a link to the previous document
* - [+PJN_jump+] : the droplist to jump to the selected document
* - [+PJN_index+] : the link to return to the index page
* - [+PJN_next+] : a link to the next document
* - [+PJN_last+] : a link to the last document
* the following placeholders can be used for making fully customized links
* - [+PJN_firstText+] : the first document's link text
* - [+PJN_firstID+] : the first document's ID * - [+PJN_prevText+] : the previous document's link text
* - [+PJN_prevID+] : the previous document's ID
* - [+PJN_indexText+] : the text to use for the index page link
* - [+PJN_indexID+] : the index page ID
* - [+PJN_nextText+] : the next document's link text
* - [+PJN_nextID+] : the next document's ID
* - [+PJN_lastText+] : the last document's link text
* - [+PJN_lastID+] : the last document's ID
* - [+PJN_currentRecord+] : the current document's index value in the list
* - [+PJN_totalRecords+] : the total number of documents in the list
*
* PARAMETERS
*
* - startID : Int: id of document folder to start from (default: parent document id);
* - sortBy : String : Document variable to sort items by. 'menuindex' or 'id' or 'createdon', etc... (default: createdon);
* - sortHow : [ASC|DESC] : Sort order? 'ASC' or 'DESC' (default ASC);
* - displayTitle : Boolean : Display document titles instead of &prevText and &nextText (default true);
* - displayWhat : String : What to display for the title: can be `pagetitle`, `longtitle`, or `menutitle` (default: pagetitle);
* - displayFixed : Boolean : Show 'first' and 'last' links (default false);
* - usePlaceHolder : Boolean : Generate placeholders and do not output html : [+PJN_first+] , [+PJN_prev+] , [+PJN_jump+] , [+PJN_index+] , [+PJN_next+] , [+PJN_index+] (default false);
* - useJump : Boolean : Replace the index link by the select list when NOT using the placeholders (default false);
* - indexDocumentID : Int : ID of the document linked as "index". (default &startID);
* - displayNoPrevNext : Boolean : Display &noPrevNextText in place of "previous" and "next" when there is no previous or next item (default false);
* - noPrevNextText : String : Text to display if there is no Prev or Next item and &displayNoPrevNext == 1 :(default "No more records");
* - indexText : String : Title for "index" item (default "Index");
* - jumpText : String : Title for select list (default :"Please Select");
* - firstText : String : Title for "first" link (default "First");
* - prevText : String : Title for "previous" item when $displayTitle is set to false (default "Prev");
* - nextText : String : Title for "next" item when $displayTitle is set to false (default "Next");
* - lastText : String : Title for "last" item (default "Last");
* - 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]
*
* OUTPUT
*
* Menu items are not wrapped in an enclosing element. Output is anchor elements with semantic class names E.G.:
* <a href="url" class="previous">Previous Title</a> | <a href="url" class="index">Index</a> | <a href="url" class="next">Next Title</a>
* Class names are: total, currentNumber, totalNumber, first, previous, index, next, last
*
* EXAMPLE CALLS :
*
* [[PrevJumpNext? sortBy=`menuindex` &sortHow=`ASC` &displayTitle=`1`]]
*
* [[PrevJumpNext? &sortBy=`pub_date` &usePlaceHolder=true &indexDocumentID=`84` &firstText=`First` &lastText=`Last` &prevText=`Previous` &nextText=`Next` &indexText=`List of Articles` &jumpText=`Quick Access` &displayNoPrevNext=`1` &noPrevNextText=`It's the end`]]
* with these place holders in the document [+PJN_first+] [+PJN_prev+] [+PJN_jump+] [+PJN_index+] [+PJN_next+] [+PJN_last+]
*/
// Settings
if(!isset($startID)){
$startID = $modx->documentObject['parent'];
}
if(!isset($sortBy)){
$sortBy = 'createdon';
}
if(!isset($sortHow)){
$sortHow = 'ASC';
}
if(!isset($displayTitle)){
$displayTitle = 1;
}
if(!isset($displayWhat)){
$displayWhat = 'pagetitle';
}
if(!isset($titleMaxChars)){
$titleMaxChars = 0;
}
if(!isset($displayFixed)){
$displayFixed = 0;
}
if(!isset($usePlaceHolder)){
$usePlaceHolder = 0;
}
if(!isset($useJump)){
$useJump=false;
}
if(!isset($indexDocumentID)){
$indexDocumentID=$modx->documentObject['parent'];
}
if(!isset($displayNoPrevNext)){
$displayNoPrevNext=0;
}
if(!isset($noPrevNextText)){
$noPrevNextText="No more records";
}
if(!isset($indexText)){
$indexText="Index";
}
if(!isset($jumpText)){
$jumpText="Please Select";
}
if(!isset($firstText)){
$firstText="First";
}
if(!isset($prevText)){
$prevText="Prev";
}
if(!isset($nextText)){
$nextText="Next";
}
if(!isset($lastText)){
$lastText="Last";
}
if(!isset($exclude)){
$exclude=array();
} else {
$exclude = split(",",$exclude);
}
if(!isset($separator)){
$separator=" | ";
}
if(!isset($displayIndex)){
$displayIndex=1;
}
if(!isset($firstSymbol)){
$firstSymbol="";
}
if(!isset($lastSymbol)){
$lastSymbol="";
}
if(!isset($prevSymbol)){
$prevSymbol="";
}
if(!isset($nextSymbol)){
$nextSymbol="";
}
if(!isset($displayTotal)){
$displayTotal=1;
}
if(!isset($recordTypeName)){
$recordTypeName="record";
}
if(!isset($includeFolders)){
$includeFolders=1;
}
$id = $modx->documentIdentifier;
$fields='id,longtitle,pagetitle,menutitle,isfolder,hidemenu'; // what fields do you want to know
$children = $modx->getActiveChildren($startID, $sortBy, $sortHow, $fields);
$y = 1;
// sorting the documents, giving them a sequential and searchable index
foreach ($children as $child) {
if (!in_array($child['id'],$exclude) && !$child['hidemenu'] && !in_array($child['id'],$exclude) && ($includeFolders == 1 || $child['isfolder'] == 0)) {
$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;
$last = $y-1;
//////// Construction of the elements
$PJN_totalPlaceHolder = "Showing " . $recordTypeName . " <span class='currentNumber'>" . $current . "</span> of <span class='totalNumber'>" . $last . "</span>\n";
// First item
$PJN_firstPlaceHolder = "<a href='[~".$my_array[1]['id']."~]' class='first'>".$firstSymbol.$firstText."</a>" ;
$PJN_firstID= $my_array[1]['id'];
$PJN_firstText= $firstSymbol.$firstText;
// Prev item
if($prev > 0 && $displayTitle==false){
$PJN_prevPlaceHolder = "<a href='[~".$my_array[$prev]['id']."~]' class='previous'>".$prevSymbol.$prevText."</a>";
$PJN_prevID=$my_array[$prev]['id'];
$PJN_prevText=$prevSymbol.$prevText;
} elseif($prev > 0 && $displayTitle==true) {
$prevTitle = ($maxTitleChars > 0) ? substr($my_array[$prev][$displayWhat],0,$maxTitleChars) . "..." : $my_array[$prev][$displayWhat];
$PJN_prevPlaceHolder = "<a href='[~".$my_array[$prev]['id']."~]' class='previous'>".$prevSymbol.$prevTitle."</a>";
$PJN_prevID=$my_array[$prev]['id'];
$PJN_prevText=$prevSymbol.$prevTitle;
} elseif($prev == 0 && $displayNoPrevNext == true) {
$PJN_prevPlaceHolder = $noPrevNextText;
$PJN_prevID=-1;
$PJN_prevText=$noPrevNextText;
}
// Select List
$PJN_jumpPlaceHolder = '<form action="" name="jump" id="jump">
<select name="myjumpbox"
onchange="location.href=jump.myjumpbox.options[selectedIndex].value">
<option selected="selected">'.$jumpText;
foreach ($my_array as $my_page) {
$jumpTitle = ($maxTitleChars > 0) ? substr($my_page[$displayWhat],0,$maxTitleChars) . "..." : $my_page[$displayWhat];
$PJN_jumpPlaceHolder .= ' <option value="[~'.$my_page['id'].'~]">'.$jumpTitle.'</option>';
}
$PJN_jumpPlaceHolder .= '</select></form>';
// Index item
$PJN_indexPlaceHolder = "<a href='[~".$indexDocumentID."~]' class='index'>".$indexText."</a>";
// Next item
if($next <= $last && $displayTitle==false){
$PJN_nextPlaceHolder = "<a href='[~".$my_array[$next]['id']."~]' class='next'>".$nextText.$nextSymbol."</a>";
$PJN_nextText=$nextText.$nextSymbol;
$PJN_nextID=$my_array[$next]['id'];
}
elseif($next <= $last && $displayTitle==true) {
$nextTitle = ($maxTitleChars > 0) ? substr($my_array[$next][$displayWhat],0,$maxTitleChars) . "...".$nextSymbol : $my_array[$next][$displayWhat].$nextSymbol;
$PJN_nextPlaceHolder ="<a href='[~".$my_array[$next]['id']."~]' class='next'>".$nextTitle."</a>";
$PJN_nextText=$nextTitle;
$PJN_nextID=$my_array[$next]['id'];
}
elseif($current == $last && $displayNoPrevNext == true) {
$PJN_nextPlaceHolder = $noPrevNextText;
$PJN_nextText=$noPrevNextText;
$PJN_nextID=-1;
}
// Last item
$PJN_lastPlaceHolder = "<a href='[~".$my_array[$last]['id']."~]' class='last'>".$lastText.$lastSymbol."</a>";
$PJN_lastID=$my_array[$last]['id'];
$PJN_lastText=$lastText.$lastSymbol;
// //////// Output commputing modded by Oncleben31 modded by Aaron Heinrich
if ($usePlaceHolder==false) {
// Here starts the output
$output = "";
if ($displayTotal) {
$output .= "<span class=\"total\">" . $PJN_totalPlaceHolder . "</span>\n";
}
if($displayFixed==true && $prev-1>0) {
$output .= $PJN_firstPlaceHolder.$separator . "\n";
}
if ($prev>0 || $displayNoPrevNext == true) {
$output .= $PJN_prevPlaceHolder;
if ($displayIndex ==1 || $useJump==1 || $next < $last ) {
$output .= $separator;
}
}
if($useJump) {
$output .= $PJN_jumpPlaceHolder;
if ($next < $last || $displayNoPrevNext == true) {
$output .= $separator;
}
$output .= "\n";
} elseif ($displayIndex == 1) {
$output .= $PJN_indexPlaceHolder;
if ($next < $last || $displayNoPrevNext == true) {
$output .= $separator;
}
}
$output .= "\n";
if ($next < $last || $displayNoPrevNext == true) {
$output .= $PJN_nextPlaceHolder;
if ($displayFixed == true && $next+1 < $last) {
$output .= $separator;
}
$output .= "\n";
}
if($displayFixed==true && $next+1 < $last) {
$output .= $PJN_lastPlaceHolder;
$output .= "\n";
}
return $output;
}
else {
// Set PlaceHolder
$modx->setPlaceholder('PJN_total',$PJN_totalPlaceHolder);
$modx->setPlaceholder('PJN_first',$PJN_firsPlaceHolder);
$modx->setPlaceholder('PJN_firstText',$PJN_firstText);
$modx->setPlaceholder('PJN_firstID',$PJN_firstID);
$modx->setPlaceholder('PJN_prev',$PJN_prevPlaceHolder);
$modx->setPlaceholder('PJN_prevText',$PJN_prevText);
$modx->setPlaceholder('PJN_prevID',$PJN_prevID);
$modx->setPlaceholder('PJN_jump',$PJN_jumpPlaceHolder);
$modx->setPlaceholder('PJN_index',$PJN_indexPlaceHolder);
$modx->setPlaceholder('PJN_indexID',$indexDocumentID);
$modx->setPlaceholder('PJN_indexText',$indexText);
$modx->setPlaceholder('PJN_next',$PJN_nextPlaceHolder);
$modx->setPlaceholder('PJN_nextText',$PJN_nextText);
$modx->setPlaceholder('PJN_nextID',$PJN_nextID);
$modx->setPlaceholder('PJN_last',$PJN_lastPlaceHolder);
$modx->setPlaceholder('PJN_lastText',$PJN_lastText);
$modx->setPlaceholder('PJN_lastID',$PJN_lastID);
$modx->setPlaceholder('PJN_currentRecord',$current);
$modx->setPlaceholder('PJN_totalRecords',$last);
}
?><?php
/*
* **************************
* Snippet: PrevJumpNext
* By: Jeroen Bosch modded by OncleBen31 modded by Aaron Heinrich
* Modified for version 0.6 by D Russell Wagner (drwagner13), August 2009
* Date: May 2006 - August 2009
* version: 0.5 and 0.6 (based on the PrevJumpNext v0.4)
* **************************
*
******Version 0.6 changes*******
*
* This snippet is now templateable. The "usePlaceHolder" parameter is deprecated. Instead use the "tpl"
* parameter and provide a chunk with the appropriate placeholders. If a template is not provided, the
* snippet output will be the usual output as before. To call this snippet multiple times per page, it is essential
* to call it uncached: [!PrevNextJump!].
******Version 0.5 changes*******
*
* the displayTotal parameter now returns the correct number of documents
*
* PNJ now accepts the following new parameters:
*
* &displayWhat: to allow showing text other than the page title, such as the longtitle or menutitle
*
* As a step toward making this snippet fully templatable, the output when using the "usePlaceHolder" option
* now includes the following placeholders:
* - [+PJN_firstText+] : the first document's link text
* - [+PJN_firstID+] : the first document's ID * - [+PJN_prevText+] : the previous document's link text
* - [+PJN_prevID+] : the previous document's ID
* - [+PJN_indexText+] : the text to use for the index page link
* - [+PJN_indexID+] : the index page ID
* - [+PJN_nextText+] : the next document's link text
* - [+PJN_nextID+] : the next document's ID
* - [+PJN_lastText+] : the last document's link text
* - [+PJN_lastID+] : the last document's ID
* - [+PJN_currentRecord+] : the current document's index value in the list
* - [+PJN_totalRecords+] : the total number of documents in the list
*
* using the above placeholders, links can be built in a templated fashion:
* <a href="[~[+PJN_firstID+]~]">[+PJN_firstText+]</a>
* Note this is equivalent to the standard output, as given below, but the following is not:
* <tr><a href="[~[+PJN_firstID+]~]">FIRST</a></tr>
* <tr>[+PJN_firstText+]</a></tr>
*
* you can use the record numbers to make statements like "Showing record x of y."
*
* DESCRIPTION
*
* Generates links to navigate between documents in a directory.
* Highly configurable. It can display :
* - 'Showing article x of x'
* - 'Prev' and 'Next' links with or without document titles
* - 'First' and 'Last' links.
* - 'Index' link to parent folder
* - A select to jump quickly to a document
*
* Can output links or generate the following placeholders:
* the following placeholders output complete links to the referenced documents
* - [+PJN_first+] : a link to the first document
* - [+PJN_prev+] : a link to the previous document
* - [+PJN_jump+] : the droplist to jump to the selected document
* - [+PJN_index+] : the link to return to the index page
* - [+PJN_next+] : a link to the next document
* - [+PJN_last+] : a link to the last document
* the following placeholders can be used for making fully customized links
* - [+PJN_firstText+] : the first document's link text
* - [+PJN_firstID+] : the first document's ID
* - [+PJN_prevText+] : the previous document's link text
* - [+PJN_prevID+] : the previous document's ID
* - [+PJN_indexText+] : the text to use for the index page link
* - [+PJN_indexID+] : the index page ID
* - [+PJN_nextText+] : the next document's link text
* - [+PJN_nextID+] : the next document's ID
* - [+PJN_lastText+] : the last document's link text
* - [+PJN_lastID+] : the last document's ID
* - [+PJN_currentRecord+] : the current document's index value in the list
* - [+PJN_totalRecords+] : the total number of documents in the list
*
* PARAMETERS
*
* - startID : Int: id of document folder to start from (default: parent document id);
* - sortBy : String : Document variable to sort items by. 'menuindex' or 'id' or 'createdon', etc... (default: createdon);
* - sortHow : [ASC|DESC] : Sort order? 'ASC' or 'DESC' (default ASC);
* - tpl : String : name of chunk than holds the output template. ;
* - displayTitle : Boolean : Display document titles instead of &prevText and &nextText (default true);
* - displayWhat : String : What to display for the title: can be `pagetitle`, `longtitle`, or `menutitle` (default: pagetitle);
* - displayFixed : Boolean : Show 'first' and 'last' links (default false);
* - usePlaceHolder : DEPRECATED : Boolean : Generate placeholders and do not output html : [+PJN_first+] , [+PJN_prev+] , [+PJN_jump+] , [+PJN_index+] , [+PJN_next+] , [+PJN_index+] (default false);
* - useJump : Boolean : Replace the index link by the select list when NOT using the placeholders (default false);
* - indexDocumentID : Int : ID of the document linked as "index". (default &startID);
* - displayNoPrevNext : Boolean : Display &noPrevNextText in place of "previous" and "next" when there is no previous or next item (default false);
* - noPrevNextText : String : Text to display if there is no Prev or Next item and &displayNoPrevNext == 1 :(default "No more records");
* - indexText : String : Title for "index" item (default "Index");
* - jumpText : String : Title for select list (default :"Please Select");
* - firstText : String : Title for "first" link (default "First");
* - prevText : String : Title for "previous" item when $displayTitle is set to false (default "Prev");
* - nextText : String : Title for "next" item when $displayTitle is set to false (default "Next");
* - lastText : String : Title for "last" item (default "Last");
* - 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]
*
* OUTPUT
*
* Menu items are not wrapped in an enclosing element. Output is anchor elements with semantic class names E.G.:
* <a href="url" class="previous">Previous Title</a> | <a href="url" class="index">Index</a> | <a href="url" class="next">Next Title</a>
* Class names are: total, currentNumber, totalNumber, first, previous, index, next, last
*
* EXAMPLE CALLS :
*
* [[PrevJumpNext? sortBy=`menuindex` &sortHow=`ASC` &displayTitle=`1`]]
*
* [[PrevJumpNext? &sortBy=`pub_date` &usePlaceHolder=true &indexDocumentID=`84` &firstText=`First` &lastText=`Last` &prevText=`Previous` &nextText=`Next` &indexText=`List of Articles` &jumpText=`Quick Access` &displayNoPrevNext=`1` &noPrevNextText=`It's the end`]]
* with these place holders in the document [+PJN_first+] [+PJN_prev+] [+PJN_jump+] [+PJN_index+] [+PJN_next+] [+PJN_last+]
*/
// Settings
if(!isset($startID)){
$startID = $modx->documentObject['parent'];
}
if(!isset($sortBy)){
$sortBy = 'createdon';
}
if(!isset($sortHow)){
$sortHow = 'ASC';
}
if(!isset($tpl)){
$tpl = '';
}
if(!isset($displayTitle)){
$displayTitle = 1;
}
if(!isset($displayWhat)){
$displayWhat = 'pagetitle';
}
if(!isset($titleMaxChars)){
$titleMaxChars = 0;
}
if(!isset($displayFixed)){
$displayFixed = 0;
}
if(!isset($usePlaceHolder)){
$usePlaceHolder = 0;
}
if(!isset($useJump)){
$useJump=false;
}
if(!isset($indexDocumentID)){
$indexDocumentID=$modx->documentObject['parent'];
}
if(!isset($displayNoPrevNext)){
$displayNoPrevNext=0;
}
if(!isset($noPrevNextText)){
$noPrevNextText="No more records";
}
if(!isset($indexText)){
$indexText="Index";
}
if(!isset($jumpText)){
$jumpText="Please Select";
}
if(!isset($firstText)){
$firstText="First";
}
if(!isset($prevText)){
$prevText="Prev";
}
if(!isset($nextText)){
$nextText="Next";
}
if(!isset($lastText)){
$lastText="Last";
}
if(!isset($exclude)){
$exclude=array();
} else {
$exclude = split(",",$exclude);
}
if(!isset($separator)){
$separator=" | ";
}
if(!isset($displayIndex)){
$displayIndex=1;
}
if(!isset($firstSymbol)){
$firstSymbol="";
}
if(!isset($lastSymbol)){
$lastSymbol="";
}
if(!isset($prevSymbol)){
$prevSymbol="";
}
if(!isset($nextSymbol)){
$nextSymbol="";
}
if(!isset($displayTotal)){
$displayTotal=1;
}
if(!isset($recordTypeName)){
$recordTypeName="record";
}
if(!isset($includeFolders)){
$includeFolders=1;
}
$id = $modx->documentIdentifier;
$fields='id,longtitle,pagetitle,menutitle,isfolder,hidemenu'; // what fields do you want to know
$children = $modx->getActiveChildren($startID, $sortBy, $sortHow, $fields);
$y = 1;
// sorting the documents, giving them a sequential and searchable index
foreach ($children as $child) {
if (!in_array($child['id'],$exclude) && !$child['hidemenu'] && !in_array($child['id'],$exclude) && ($includeFolders == 1 || $child['isfolder'] == 0)) {
$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;
$last = $y-1;
//////// Construction of the elements
$PJN_totalPlaceHolder = "Showing " . $recordTypeName . " <span class='currentNumber'>" . $current . "</span> of <span class='totalNumber'>" . $last . "</span>\n";
// First item
$PJN_firstPlaceHolder = "<a href='[~".$my_array[1]['id']."~]' class='first'>".$firstSymbol.$firstText."</a>" ;
$PJN_firstID= $my_array[1]['id'];
$PJN_firstText= $firstSymbol.$firstText;
// Prev item
if($prev > 0 && $displayTitle==false){
$PJN_prevPlaceHolder = "<a href='[~".$my_array[$prev]['id']."~]' class='previous'>".$prevSymbol.$prevText."</a>";
$PJN_prevID=$my_array[$prev]['id'];
$PJN_prevText=$prevSymbol.$prevText;
} elseif($prev > 0 && $displayTitle==true) {
$prevTitle = ($maxTitleChars > 0) ? substr($my_array[$prev][$displayWhat],0,$maxTitleChars) . "..." : $my_array[$prev][$displayWhat];
$PJN_prevPlaceHolder = "<a href='[~".$my_array[$prev]['id']."~]' class='previous'>".$prevSymbol.$prevTitle."</a>";
$PJN_prevID=$my_array[$prev]['id'];
$PJN_prevText=$prevSymbol.$prevTitle;
} elseif($prev == 0 && $displayNoPrevNext == true) {
$PJN_prevPlaceHolder = $noPrevNextText;
$PJN_prevID=-1;
$PJN_prevText=$noPrevNextText;
}
// Select List
$PJN_jumpPlaceHolder = '<form action="" name="jump" id="jump">
<select name="myjumpbox"
onchange="location.href=jump.myjumpbox.options[selectedIndex].value">
<option selected="selected">'.$jumpText;
foreach ($my_array as $my_page) {
$jumpTitle = ($maxTitleChars > 0) ? substr($my_page[$displayWhat],0,$maxTitleChars) . "..." : $my_page[$displayWhat];
$PJN_jumpPlaceHolder .= ' <option value="[~'.$my_page['id'].'~]">'.$jumpTitle.'</option>';
}
$PJN_jumpPlaceHolder .= '</select></form>';
// Index item
$PJN_indexPlaceHolder = "<a href='[~".$indexDocumentID."~]' class='index'>".$indexText."</a>";
// Next item
if($next <= $last && $displayTitle==false){
$PJN_nextPlaceHolder = "<a href='[~".$my_array[$next]['id']."~]' class='next'>".$nextText.$nextSymbol."</a>";
$PJN_nextText=$nextText.$nextSymbol;
$PJN_nextID=$my_array[$next]['id'];
}
elseif($next <= $last && $displayTitle==true) {
$nextTitle = ($maxTitleChars > 0) ? substr($my_array[$next][$displayWhat],0,$maxTitleChars) . "...".$nextSymbol : $my_array[$next][$displayWhat].$nextSymbol;
$PJN_nextPlaceHolder ="<a href='[~".$my_array[$next]['id']."~]' class='next'>".$nextTitle."</a>";
$PJN_nextText=$nextTitle;
$PJN_nextID=$my_array[$next]['id'];
}
elseif($current == $last && $displayNoPrevNext == true) {
$PJN_nextPlaceHolder = $noPrevNextText;
$PJN_nextText=$noPrevNextText;
$PJN_nextID=-1;
}
// Last item
$PJN_lastPlaceHolder = "<a href='[~".$my_array[$last]['id']."~]' class='last'>".$lastText.$lastSymbol."</a>";
$PJN_lastID=$my_array[$last]['id'];
$PJN_lastText=$lastText.$lastSymbol;
// //////// Output commputing modded by Oncleben31 modded by Aaron Heinrich
//if ($usePlaceHolder==false) {
if ($tpl=='') {
// Here starts the output
$output = "";
if ($displayTotal) {
$output .= "<span class=\"total\">" . $PJN_totalPlaceHolder . "</span>\n";
}
if($displayFixed==true && $prev-1>0) {
$output .= $PJN_firstPlaceHolder.$separator . "\n";
}
if ($prev>0 || $displayNoPrevNext == true) {
$output .= $PJN_prevPlaceHolder;
if ($displayIndex ==1 || $useJump==1 || $next < $last ) {
$output .= $separator;
}
}
if($useJump) {
$output .= $PJN_jumpPlaceHolder;
if ($next < $last || $displayNoPrevNext == true) {
$output .= $separator;
}
$output .= "\n";
} elseif ($displayIndex == 1) {
$output .= $PJN_indexPlaceHolder;
if ($next < $last || $displayNoPrevNext == true) {
$output .= $separator;
}
}
$output .= "\n";
if ($next < $last || $displayNoPrevNext == true) {
$output .= $PJN_nextPlaceHolder;
if ($displayFixed == true && $next+1 < $last) {
$output .= $separator;
}
$output .= "\n";
}
if($displayFixed==true && $next+1 < $last) {
$output .= $PJN_lastPlaceHolder;
$output .= "\n";
}
return $output;
}
else {
// Set PlaceHolder
$modx->setPlaceholder('PJN_total',$PJN_totalPlaceHolder);
$modx->setPlaceholder('PJN_first',$PJN_firsPlaceHolder);
$modx->setPlaceholder('PJN_firstText',$PJN_firstText);
$modx->setPlaceholder('PJN_firstID',$PJN_firstID);
$modx->setPlaceholder('PJN_prev',$PJN_prevPlaceHolder);
$modx->setPlaceholder('PJN_prevText',$PJN_prevText);
$modx->setPlaceholder('PJN_prevID',$PJN_prevID);
$modx->setPlaceholder('PJN_jump',$PJN_jumpPlaceHolder);
$modx->setPlaceholder('PJN_index',$PJN_indexPlaceHolder);
$modx->setPlaceholder('PJN_indexID',$indexDocumentID);
$modx->setPlaceholder('PJN_indexText',$indexText);
$modx->setPlaceholder('PJN_next',$PJN_nextPlaceHolder);
$modx->setPlaceholder('PJN_nextText',$PJN_nextText);
$modx->setPlaceholder('PJN_nextID',$PJN_nextID);
$modx->setPlaceholder('PJN_last',$PJN_lastPlaceHolder);
$modx->setPlaceholder('PJN_lastText',$PJN_lastText);
$modx->setPlaceholder('PJN_lastID',$PJN_lastID);
$modx->setPlaceholder('PJN_currentRecord',$current);
$modx->setPlaceholder('PJN_totalRecords',$last);
return $modx->getChunk($tpl);
}
?>