Share This
 
All Posts  /  Kentico Development Tips  /  September 01, 2015 

How To Create Previous & Next Links for Kentico Blog Posts

A popular feature that many designers like to add in their Kentico CMS blogs are links allowing the user to easily navigate to the previous or next blog post. Unfortunately, there isn’t really a straightforward way describing how to do this within Kentico. In this post I will detail how you can use Kentico's Repeaters and Page Type Transformations to set up blog post previous and next links in just a few minutes!
 

Transformations

In the BlogPost page type create two transformations. One for the previous blog post, and one for the next one.

In these transformations, add your link to the previous or next post using the GetDocumentUrl() transformation method.

Blog Post Next Item Transformation

 

Repeaters

On your blog post page template you will need to add two repeaters. One for the previous link, and one for the next.

For the previous repeater add your usual settings & modify the following settings:

Page types: CMS.BlogPost
Select top N pages: 1
Where condition: BlogPostID = (select top 1 BlogPostID from CONTENT_BlogPost where BlogPostDate < '{%BlogPostDate%}' order by BlogPostDate desc)
Columns: DocumentUrlPath, SiteName, NodeAliasPath
Transformation: Select the transformation you made for the Previous blog post link

Adding the columns is recommended but not required. By limiting the number of columns returned, your request is more efficient.

For the next repeater add the same settings as above except:

Where condition: BlogPostID = (select top 1 BlogPostID from CONTENT_BlogPost where BlogPostDate > '{%BlogPostDate%}' order by BlogPostDate)
Transformation: Select the transformation you made for the Next blog post link

Blog post next link repeater


Voila! You now have previous and next links for your blog post page!

 

Show More
Share This
 
Comments
Blog post currently doesn't have any comments.
*
 Security code
*
ADD COMMENT
Social Buzz

Get in Touch

Contact

Contact
t: 973.539.5255
f: 973.917.4730

Visit

Visit
715 Main Street
Boonton, NJ 07005

Locations

Locations
Boonton
Dallas
Jersey City
Boulder

Send Us a Message




 Security code