MENU

Adding previous and next links to the modules detail pages

  Previous article Next article  

This tutorial demonstrates the power and simplicity of Smarty template code by using it to add previous and next buttons to the CMS Made Simple™ News module without any UDT.

  How to use

Create a new News summary template, named "prev_next_links", with the content:

{foreach from=$items item=the_entry}
  {capture append='allIDs'}{$the_entry->id}{/capture}
  {capture append='allURLs'}{$the_entry->moreurl}{/capture}
{/foreach}

{foreach from=$allIDs item=someID name=findmyID}
  {if $currentID == $someID}{$currentkey = $smarty.foreach.findmyID.index}{/if}
{/foreach}

<p class="next-button">
  {$nextkey = $currentkey+1}
  {if isset($allURLs[$nextkey])}
    <a href="{$allURLs[$nextkey]}">Next article</a>&nbsp;&gt;
  {/if}
</p>

<p class="prev-button">
  {$prevkey = $currentkey-1}
  {if isset($allURLs[$prevkey])}
    &lt;&nbsp;<a href="{$allURLs[$prevkey]}">Previous article</a>
  {/if}
</p>

In the detail template of the module you should add these lines at the spot you want to have the buttons in the template:

{$currentID = $entry->id scope=global}
{News summarytemplate='prev_next_links'}

  Working example



Buy Me A Coffee


  Comment Form

Click here to open the form


  3 Comments

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Adding previous and next links to the modules detail pages

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1
  Last updated: 30-09-2020
  Comments: 3
  http://cms.ms/4xjt


Buy Me A Coffee




Advertisement


Ads help me to help you! Buy products from these advertisers!