Давненько мной был подправлен скрипт PrevJumpNext v0.3... C его помощью можно реализовать то, что вы хотите - только слегка подправьте код. Кроме того дополнительно выводится и аннотация соседних статей.
В общем по-порядку:
1. Создаем сниппет, я назвал его TwoPrevNext
<?php
/* **************************
* Snippet: NextThree
* By: LeonCrab
* Date: February 2008
* version: 0.1 (based on the PrevJumpNext v0.3)
* **************************
*
* Function:
* Generates links to Next, Next+1, Next+2 document of a same directory.
*
* 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)
* - noPrevNextText : Text to display if there is no Prev or no Next element :(default "-")
*
* The output use <div> to allow you to CSS the links
*
* Enjoy and don't esitate to ask new features
* Exemples :
*
* [[NextThree? &sortBy=`menuindex` &sortHow=`ASC` &linkAncor='longtitle']]
*
*/
# 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
}
# Ancor for links. 'longtitle' or 'pagetitle'
if(!isset($linkAncor)){
$linkAncor = 'pagetitle'; // default by 'pagetitle'
}
//
// 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,longtitle,introtext,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++;
}
$next = $current+1;
$nexttwo = $current+2;
$nexthree = $current+3;
// ### Construction oh the elements
// Next item
if($next <= $limit){
$PJN_nextPlaceHolder ="<a href='[~".$my_array[$next]['id']."~]'>".$my_array[$next][$linkAncor]."</a>."." ".$my_array[$next]['introtext'];
} elseif($next > $limit) {
$PJN_nextPlaceHolder = "<a href='[~".$my_array[$current-3]['id']."~]'>".$my_array[$current-3][$linkAncor]."</a>."." ".$my_array[$current-3]['introtext'];
}
// Nexttwo item
if($nexttwo <= $limit){
$PJN_nextdvaPlaceHolder ="<a href='[~".$my_array[$nexttwo]['id']."~]'>".$my_array[$nexttwo][$linkAncor]."</a>."." ".$my_array[$nexttwo]['introtext'];
} elseif($nexttwo > $limit) {
$PJN_nextdvaPlaceHolder = "<a href='[~".$my_array[$current-2]['id']."~]'>".$my_array[$current-2][$linkAncor]."</a>."." ".$my_array[$current-2]['introtext'];
}
// Nextthree item
if($nexthree <= $limit){
$PJN_nexttriPlaceHolder ="<a href='[~".$my_array[$nexthree]['id']."~]'>".$my_array[$nexthree][$linkAncor]."</a>."." ".$my_array[$nexthree]['introtext'];
} elseif($nexthree > $limit) {
$PJN_nexttriPlaceHolder = "<a href='[~".$my_array[$current-1]['id']."~]'>".$my_array[$current-1][$linkAncor]."</a>."." ".$my_array[$current-1]['introtext'];
}
// #### Output commputing modded by Oncleben31
// Here starts the output
$output = "";
$output .= "<div id='NextThree'>";
$output .= "<div class='tpn'>".$PJN_nextPlaceHolder."</div><br />";
$output .= "<div class='tpn'>".$PJN_nextdvaPlaceHolder."</div><br />";
$output .= "<div class='tpn'>".$PJN_nexttriPlaceHolder."</div>";
$output .= "</div>";
return $output;
?>
2. В шаблоне для статей в место вывода ссылок на соседние страницы вставляете
[[TwoPrevNext? &sortBy=`menuindex` &sortHow=`ASC`]]
Можно выбрать по чем сортировать и порядок сортировки.
Производится вывод 3 следующих статей, если они существуют или 3 предыдущих, если следующих нет...
Кроме ссылки на соседнюю статью производится вывод и аннотации этой статьи.
В общем ройтесь в коде... и меняйте его под ваши нужды.
О том, как это работает можно посмотреть на любой внутренней странице
сайта о садоводстве, ландшафтном дизайне и растениях
Кстати, под ваши цели подходит и сам PrevJumpNext v0.3