MODx Community Forums
The MODx Blog
Donations
Feedburner Feeds
Documentation
Bugs & Requests
The Wiki
download MODx
plugins, modules, snippets
online demo
Dec 04, 2008, 12:12 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search via SMF
or Google:
modx forums
all of modxcms.com
web
MODxCMS.com
Forums
Help
Login
Register
News
:Read
Frequently Asked Questions (FAQ)
MODx Community Forums
»
Add-ons, Extensions & Elements
»
Module, Plugin & Snippet Usage
(Moderators:
zi
,
PaulGregory
)
»
Adding Next and Previous Links
Pages: [
1
]
Go Down
« Previous topic
Next topic »
Print
Author
Topic: Adding Next and Previous Links (Read 4668 times)
0 Members and 1 Guest are viewing this topic.
moondog
Jr. Member
Posts: 7
Adding Next and Previous Links
«
on:
Jan 03, 2006, 07:01 AM »
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;
Quote
<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>
Quote
[!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
Logged
moondog
Jr. Member
Posts: 7
Re: Adding Next and Previous Links
«
Reply #1 on:
Jan 03, 2006, 10:00 AM »
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;
Quote
[!NewsListing? &startID=`42` &summarize=`3` &paginate=`1` &alwaysshow=`1`!]<br /><br />Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles<br />[+previous+] [+pages+] [+next+] <div> </div>
Where the folder i've called News has a value of 42 in the () next to the folder icon in the Manager?
Logged
Mark
Coding Team
Posts: 3,247
Ditto Developer
Re: Adding Next and Previous Links
«
Reply #2 on:
Jan 03, 2006, 02:04 PM »
Quote
Is it possible to add links to navigate through blog entries?
There are many snippets that do that including this one:
Code:
//
// **************************
// 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;
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
moondog
Jr. Member
Posts: 7
Re: Adding Next and Previous Links
«
Reply #3 on:
Jan 04, 2006, 03:35 AM »
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.
«
Last Edit: Jan 04, 2006, 04:22 AM by moondog
»
Logged
Mark
Coding Team
Posts: 3,247
Ditto Developer
Re: Adding Next and Previous Links
«
Reply #4 on:
Jan 04, 2006, 10:20 AM »
&startID=`idoffolderwithchildren`
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
moondog
Jr. Member
Posts: 7
Re: Adding Next and Previous Links
«
Reply #5 on:
Jan 04, 2006, 11:04 AM »
Mark,
Thanks very much for all your help.
Works like a charm now
Logged
OncleBen31
Sr. Member
Posts: 283
I believe in MODx!
Re: Adding Next and Previous Links
«
Reply #6 on:
Apr 13, 2006, 04:10 PM »
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.
Code:
//
// **************************
// 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;
Logged
Mark
Coding Team
Posts: 3,247
Ditto Developer
Re: Adding Next and Previous Links
«
Reply #7 on:
Apr 28, 2006, 02:23 PM »
Very cool! Can you please put this new snippet in its own thread and make the snippet a .txt download? Thanks!
Logged
Documentation
TRAC (Bugtracker)
Forum
How to get help
User Wiki
Credits
SVN Server
Ditto HQ
Stable Download
Development Download
OncleBen31
Sr. Member
Posts: 283
I believe in MODx!
Re: Adding Next and Previous Links
«
Reply #8 on:
Apr 28, 2006, 04:18 PM »
I want to do some modification, like using placeholder. I will post it when I achieved it.
Logged
OncleBen31
Sr. Member
Posts: 283
I believe in MODx!
Re: Adding Next and Previous Links
«
Reply #9 on:
May 02, 2006, 04:12 AM »
I've created a new topic dedicated to PrevJumpNext snippet :
http://modxcms.com/forums/index.php/topic,4300.msg31245.html#msg31245
Logged
Pages: [
1
]
Go Up
Print
« Previous topic
Next topic »
Jump to:
Please select a destination:
-----------------------------
Announcements
-----------------------------
=> Important News
=> Security Notices
-----------------------------
Commercial Support
-----------------------------
=> [CS] About Commercial Support
-----------------------------
Development & Coding
-----------------------------
=> Commercial Inquiries & Bounties
=> Core Code
===> MODx Next
===> xPDO
=> Module, Plugin & Snippet Creation and Modification
=> In Development
=> Templates
=> Internationalization
===> Bulgarian
===> Chinese
===> Czech
===> Dutch
===> French
===> German
===> Irish
===> Italian
===> Japanese
===> Polish
===> Portuguese
===> Russian
===> Slovak
===> Spanish
===> Swedish
===> Persian - فارسي
-----------------------------
Support
-----------------------------
=> Release Support
===> 0.9.6.2
===> 0.9.6.1
===> 0.9.6
===> 0.9.5 and earlier
=> General Support
===> MODx 101
===> E-Commerce, E-Marketing, Analytics & SEO
===> Hosting Experiences
===> IIS / Windows Hosting Issues
=> Documentation, Tips & Tricks
===> Documentation Suggestions & Corrections
-----------------------------
Add-ons, Extensions & Elements
-----------------------------
=> Module, Plugin & Snippet Usage
=> General Repository Items Support
=> Navigation & Tagging/Taxonomy
===> Wayfinder & DropMenu
=> Creating & Repurposing Content
===> Ditto
===> Jot
===> QuickEdit
=> Users, Authentication & Personalization
===> WebloginPE
===> WebLogin, WebSignup and WebChangePwd
=> Rich Text Editors & File Browser
===> TinyMCE
===> FCKeditor
===> MCPuck File Browser
=> Forms, Form Processing & Anti-Spam
===> eForm
=> Search
===> AjaxSearch
=> E-business
=> Polls, Calendars, Address Book and Community
=> Third-party integrations
=> Images, Videos & Podcasts
===> MaxiGallery
=> Manager, Parser & the Core
===> Backup & Versioning
===> Doc Finder
===> ManagerManager
===> PHx
=> Templates
-----------------------------
General Discussions
-----------------------------
=> General MODx Discussions
=> Web Design and Development
=> Wishlist
=> You and Your Sites
=> modxcms.com Discussions and Suggestions
=> Off-topic
-----------------------------
Czech Community
-----------------------------
=> Oznámení
===> Důležitá oznámení/novinky
===> Bezpečnost
=> Podpora
===> FAQ (často kladené otázky)
===> Instalace
===> Moduly, pluginy, "snippets & code" (šablony zdrojových kódů)
===> Design & Šablony
=> Dokumentace, tutoriály (návody) a překlady
===> Dokumentace
===> Tutoriály (návody)
===> Překlady (lokalizace)
=> Komunita
===> Oznámení
===> Představte se, prosím
===> Ukázky práce
===> Různé aneb cokoli co se jinam nehodí
-----------------------------
Bulgarian Community
-----------------------------
=> Поддръжка
===> Често задавани въпроси
===> Инсталация
===> Модули, Плъгини, Снипети и код
===> Дизайн и Шаблони
=> Документация, Ръководства и Превод
===> Документация
===> Ръководства
===> Превод
=> Общество
===> Съобщения
===> Представете се
===> Представете сайта си
===> Дискусии извън MODx
-----------------------------
Dutch Community
-----------------------------
=> Ondersteuning
===> Veel gestelde vragen
===> Modules, Plugins, Snippets & Code
===> Design & Templates
=> Documentatie, Tutorials en Vertalingen
===> Documentatie
===> Tutorials
===> Vertalingen
=> Community
===> Aankondigingen
===> Stel jezelf voor
===> Site Showcase
===> De stamkroeg
-----------------------------
Finnish Community
-----------------------------
=> Tuki
===> UKK
===> Asennus
===> Moduulit, liitännäiset, koodinpätkät
===> Ulkoasu/Sivustopohjat
=> Dokumentaatio, oppaat ja käännökset
===> Dokumentaatio
===> Käännökset
===> Oppaat
=> Yhteisö
===> Tiedotteet
===> Esittele itsesi
===> MODx sivustosi
===> Kahvihuone
-----------------------------
Filipino Community
-----------------------------
=> Suporta
===> Kadalasang tanong
===> Instalasyon
===> Moduler, Maidadagdag, Karagdagang mga Code
===> Desenyo at Templates
=> Dokumentasyon, Mga Turo, Mga Salin
===> Dokumentasyon
===> Mga Turo
===> Mga Salin
=> Kumunidad
===> Anunsyo
===> Ipakilala ang sarili
===> Ang Galing ng pinoy
===> Tsismisan atbp
-----------------------------
French Community
-----------------------------
=> Support
===> FAQ
===> Installation
===> Module, plugin, snippets
===> Design/Templates
=> Documentation, Tutoriels et Traductions
===> Documentation
===> Traduction
===> Tutoriels
=> Communauté
===> Annonces
===> Présentez vous
===> Vos sites
===> Le Bistrot Français
-----------------------------
German Community
-----------------------------
=> Support (de)
===> FAQ (de)
===> Installation (de)
===> Module, Plugins, Snippets & Code (de)
===> Design & Templates (de)
=> Dokumentation, Tutorials und Übersetzung
===> Dokumentation
===> Tutorials (de)
===> Übersetzung
=> Community (de)
===> Ankündigungen
===> Stellt Euch vor
===> Beispielseiten
===> Off Topic / Verschiedenes
-----------------------------
Irish Community
-----------------------------
=> Tacaíocht
===> CC Ceisteanna Coitianta
===> Breiseáin (cláir bhreise), Snippets & Comhaid
===> Suiteáil
===> Dearadh & Teimpléid
=> Doiciméid, Teagascóireacht agus Aistriúchán
===> Doiciméadú
===> Teagascóireacht
===> Aistriúchán
=> Pobal
===> Fógraí
===> Cuir Tú Féin in Aithne
===> Gailearaí an Láithreáin
===> Caifé / An Tábhairne / Ábhar Cainte Eile / Ilghnéitheach
-----------------------------
Italian Community
-----------------------------
=> Supporto
===> FAQ
===> Installazione
===> Moduli, Plugin, Snippet e altro codice
===> Web Design e Template
=> Documentazione, Tutorial e Traduzione
===> Documentazione
===> Tutorial
===> Traduzione
=> Comunità
===> Annunci
===> Presentazioni
===> Siti in vetrina
===> Chiacchiere in libertà
-----------------------------
Japanese Community
-----------------------------
=> サポート
===> 良くある質問
===> インストール
===> モジュール・プラグイン・スニペット・本体
===> デザインやテンプレート
=> マニュアル・テュートリアル・翻訳
===> マニュアル
===> 事例集、テュートリアル
===> 日本語化
=> コミュニティ
===> お知らせ
===> MODxサイト展示場
===> 自己紹介
===> 雑談
===> 国産リソース
-----------------------------
Persian Community
-----------------------------
=> پشتيباني
===> راهنما
===> نصب
===> ماژول , پلاگین ها , کد ها و جزییات
===> طراحی و قالب ها
=> مستند سازی , آموزش ها و ترجمه ها
===> مستند سازی
===> آموزش ها
===> ترجمه ها
=> انجمن ها
===> اخبار
===> معرفی کردن خود
===> نمایش دادن سایت ها
===> بحث های عمومی و سایر موضوعات
-----------------------------
Polish Community
-----------------------------
=> Wsparcie
===> FAQ
===> Instalacja
===> Moduły, pluginy, snipety i kod
===> Wygląd i szablony
=> Dokumentacja, tutoriale i tłumaczenie
===> Dokumentacja
===> Tutoriale
===> Tłumaczenie
=> Społeczność
===> Ogłoszenia
===> Przedstaw się
===> Twój serwis WWW
===> Hyde Park
-----------------------------
Portuguese Community
-----------------------------
=> Suporte
===> FAQ - Dúvidas Frequentes
===> Instalação
===> Módulos, Plugins, Snippets e Código
===> Design e Templates
=> Documentação, Guias e Traduções
===> Documentação
===> Guias
===> Traduções
=> Comunidade
===> Anúncios
===> Apresente-se!
===> Bar da esquina (fora de tópico)
===> Portfólio de Sites
-----------------------------
Russian Community
-----------------------------
=> Поддержка
===> ЧАВО (FAQ)
===> Установка
===> Модули, плагины, сниппеты и код
===> Дизайны и шаблоны
=> Документация, Уроки, Перевод
===> Документация
===> Уроки
===> Перевод
=> Сообщество
===> Объявления
===> Представьтесь публике
===> Галерея сайтов
===> Диван
-----------------------------
Scandinavian Community
-----------------------------
=> Support
===> Frågor och svar
===> Installation
===> Moduler, plugins, snippets och kod
===> Design & sidmallar
=> Dokumentation, guider och översättningar
===> Dokumentation
===> Guider
===> Översättningar
=> Webbgemenskap
===> Meddelanden
===> Presentera dig själv
===> Visa upp dina webbsidor
===> Ordet fritt
-----------------------------
Spanish Community
-----------------------------
=> Soporte
===> FAQ
===> Instalación
===> Modulos, Plugins, Snippets & Código
===> Diseño y plantillas
=> Documentación, Tutoriales y Traducciones
===> Documentatción
===> Tutoriales
===> Traducciones
=> Comunidad
===> Anuncios
===> Presentaciones personales
===> Muestra de sitios
===> El Café
-----------------------------
TÜRKÇE (Turkish)
-----------------------------
=> Destek
===> SSS
===> Kurulum
===> Modüller, Pluginler, Snippetlar & Kodlar
===> Dizayn & Temalar
=> Belgeleme, Eğitmenler ve Çeviri
===> Belgeleme
===> Eğitmenler
===> Çeviri
=> Topluluk
===> Duyurular
===> Kendinizi Tanıtın
===> Site Vitrini
===> Konu Dışı