-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add next/previous navigation #31
base: 1.x
Are you sure you want to change the base?
Conversation
This is working for me locally, but is failing tests - I'm at a loss as to why it is failing https://github.com/localgovdrupal/localgov_blogs/actions/runs/8401705613/job/23010407547?pr=31 |
@andybroomfield to take a look. Feelings at merge Tuesday is that this should be optional so sites can opt in. There isn't explicit ordering for blogs so the assumption is this will be ordered by date, but this isn't guaranteed. |
They are initially ordered by creation date - however this can be manipulated on the channel node: |
I've managed to do a quick test and get it working. However I'm actully not sure this is the right approach here, trying to use the same method as guides which is a hierarchical content type with explicit ordering, and blog posts that are primarlly in date order, with some being pulled out to be featured. This is making the feature a little complicated to implement as I see that we are tracking new blog posts that are being added just so they can be re-ordered. However sometimes blog posts can be added with different published dates so this would result with them being out of order so having to be reorded each time (On our news pages, often our comms team will have several draft stories being worked on, and they will adjust the date before publishing). Instead, I belive the better approach is to lean into this being date based content, and make the next / previous links behave as a way of moving to the next / previous blog post based on the date, using the same method as wordpress. I feel this would also be closer to how blog authors would expect it and would like to hear from them on their user needs.
If there is a need to re-order a post, the current established pattern in news where we change the post date. Maybe its worth looking at Nextpre module module? Things to consider
|
Discussing with @ekes and @andybroomfield at Merge Tuesday:
@AWearring what do you think? Is this something you want to re-work or do you want someone else to dive in a give it a go? |
@finnlewis I'll have a crack at it (time allowing), if I get stuck I will happily pass on to someone else to have a go at it |
So it should be |
Hi @AWearring yep it should be |
Delete `BlogPrevNextBlock.php` from `src/plugin/block` already placed in `src/Plugin/Block`
@millnut @andybroomfield @markconroy @stephen-cox @ekes @opdavies |
- Use blog channel as a condition - set the template name correctly - Use the node->id as a cache tag
Have pushed fix for missing links in block. Now just needs the test. |
@andybroomfield |
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Template looks fine to me now, I'll leave others to comment on the backend items.
Not urgent, but would be good to this approved soon. |
->condition('localgov_blog_channel', $current_blog_channel) | ||
->condition('status', 1) | ||
->condition('langcode', $current_langcode) | ||
->sort('localgov_blog_date', $sort) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made two posts on the same day. They don't get any previous next links. I think this is because the granularity of the date in day. If you have two posts on the same day it's not getting to them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekes I think this is becuase the blog date field is a date, not a date time. Simmilar issue in news as it's not got time granuallity. I suggest for this PR we add in checking for a page updated also, and then revise these date fields on blogs and news and convert them to datetime.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ekes @andybroomfield If eiether of you have some time to look at adding in a check for page updated that would be awesome - I have very limited time at the moment to look at this so any help would be greatly appreciated.
Adds a second blog channel and alternate the posts between them and check the correct next and previous links are established.
- Adds test to check that blog posts on the same day follow next / prev logic - Amend the next / prev block by allowing for search of same day posts, using the created time as the secondary sort order. This involves finding all posts including the current that could be valid, and then searching the resultant array to find the next / previous.
This is ready for review again @AWearring and @ekes. I've also tried to account for blog posts being on the same day. The issue here is that there is insufficent granularity for the If we would rarther skip this and try to change |
Added next/previous navigation based upon localgov_guides