Streaming live at 10am (PST)

Native linking to previous and next post or page using CMS


#1

I've set up a collection of blog posts, and made the appropriate pages. Everything works like a charm, but I would like to insert links to the previous and next post.


View Next Collection Item on Template Page
Next article on CMS option
Full CMS Lightbox!
How do I add a link from one collection template page to another in the same collection?
Adding footer across multiple pages
Native linking to previous and next post with titles using CMS
Native linking to previous and next post with titles using CMS
Native linking to previous and next post with titles using CMS
#2

Hello @GarlandBriggs,
I am sorry, but in this first release CMS do not have such function, yet.
I have a workaround for linking "in between" but it will be pretty much work when there is many items in the collection (like blog-posts). confused

Regards,
Anna


#3

When Webflow start to biild this, please also build the option: next/previous page.


#4

Ah, I see. But you have a workaround you say – would you like to share it?


#5

Sure, I am glad to share smiley
When you are creating item in any collection, it is shows how dynamic link to this item will look like. So I just added fields with links to the previous and next items in this collection, where I manually typing links.

Like I said, it will be pretty much work when there is many items. I used it for linking in between albums

Regards,
Anna


How to navigate between CMS collection items
Blog Posts - Adding an Older/Newer Post Link
#6

Nice idea Sabanna! i will use this until than!


#7

Any updates on this? This would be awesome to have, if not possible already? The workaround of @sabanna is nice, but will be a real pain with a lot of articles. I'm currently working on a support kind of site with a lot of courses/trainings, which they want to present in a course-kind of way with Next/Previous training buttons.


#8

Happy to like this too. It could be similar inbuilt feature like the "previous slide" / "next slide" is.


#9

+1 Would love to have this feature.


#10

+1 paging for the CMS would be awesome


#11

Actually there is a slightly simpler way to make next or previous actions then sabanna suggests.
In my case I reused the reference field linking to itself, creating kind of a loop.

  1. First you need to create a reference field in the same collection. Name it Next.
  2. Link the reference to it self.

  1. Save the collection.
  2. Go to the Editor and create a button, name it "Next". In the Link settings make sure to click on the "A collection detail page" and to pick from the dropdown "references > next".

  1. Go back to collections and in the items list and pick one item.
  2. In the "Next" field select the item that should appear next as the "Next" button triggered. (Repeat for each item)

Same way can be created previous button.


Blog Posts - Adding an Older/Newer Post Link
Automatic NEXT/PREVIOUS product button for ecommerce with CMS Dynamic list
#12

Great idea!!!! :clap: And so simple!


#13

I was about to suggest the same thing! Thanks! :thumbsup:


#14

This worked perfectly for me.

I added two toggles to my collection, one "First" and one "Last" that I turn on if the lesson (my site is an online course) is the first or last in the unit.

This allows me to show or hide the Previous and Next buttons when appropriate. Maybe that'll help someone else, too!


#15

Guys, i know its holiday time... and your working on great stuff.. but please when that is finished do some small projects like this kind of things it would make the community love your more!:relaxed:


#16

Any updates? :slight_smile:


#17

It might be worth noting that I had to refresh after adding the "next" reference field to the collection before I was able to link it from my template. Just throwing that out there in case anyone else runs into this same issue :slight_smile: I thought it wasn't working at first.


#18

When will this feature be available? @thesergie


#19

I solved this issue without manually assigning anything in the CMS. If the post order is changed or if posts are deleted, the buttons update automatically. A working version of this can be found here: http://www.hammerhouse.io/post/jonathanroy

How it works:
-A dynamic list containing your posts is added to the post template page.
-Webflow automatically adds the class 'w--current' to the current post.
-jQuery searches the dynamic list for that class and the posts that come before and after it.
-jQuery updates your next / previous button anchor tags.


Step A - Add the the post list:
1) At the bottom of the post template page, add a Dynamic List containing all posts
2) Assign the ID 'post_list'




Step B - Add dynamic links:
3) Add a Text Link element inside the Dynamic Item
4) Set the link to Current Post
5) Set the text to the post's Name field




Step C - Add ID's to buttons:
6) Add ID 'previous_button' to previous post button
7) Add ID 'next_button' to next post button




Step D - Paste the code:
8) In the post template page settings, add the following code inside the head tag section:
-CSS is included to hide the post list on the published page



Code:

<style>#post_list{display: none;}</style>

<script>
  var Webflow = Webflow || [];
  Webflow.push(function () { 
    
    var next_href = $('#post_list .w--current').parent().next().find('a').attr('href');
    var previous_href = $('#post_list .w--current').parent().prev().find('a').attr('href');
    
    //if last post in list
    if(next_href == undefined) {
      next_href = $('#post_list').children().children().first().find('a').attr('href');
      $('#next_button').fadeOut(); //optional - remove if you want to loop to beginning
    }
    
    //if first post in list
    if(previous_href == undefined) {
      previous_href = $('#post_list').children().children().last().find('a').attr('href');
      $('#previous_button').fadeOut();  //optional - remove if you want to loop to end
    }
    
    //apply hrefs to next / previous buttons
    $('#next_button').attr('href', next_href);
    $('#previous_button').attr('href', previous_href);
    
  });
</script>

Next/Previous buttons for dynamic lists?
Blog Posts - Adding an Older/Newer Post Link
#20