3

I want an overview of articles sorted by their post date (some articles will be posted back in 2007). But then the possibility should be there to move an article back to the top of the list (we want to recycle old content). We don't want to change de post date manually, because this is valuable information (so the post date should be the original post date), I also don't want to use the updated date, since sometimes you'll need to edit a node without having it move back to the top of the list.

I was thinking, Weight module, but maybe there are better alternatives, i don't need as much control on the sorting as the weight module is giving. I'm not afraid of creating (small) custom modules, if i'm properly guided through the Drupal API.

Ideally i'd want: 1. an action 'move to top' on the content overview page and a simple checkbox on a node edit page: move to top. 2. an action and checkbox that says: reset to post date, so that we can put it back in the order it's intended to be...

I was thinking a date field, that gets updated to now() every time the 'move to top' action is called... and is emptied when 'reset to post date' is chosen...

Does anyone know a module that does this? Or can guide me in creating it?

Kind regards and thank you in advance

The workflow i'm going for:

  1. Enable custom module (i know how to create a module and activate it)
  2. Add option in each node type I wish to have this function (maybe in the publishing options, simple checkbox should suffice)
  3. In a node have a checkbox 'Move back to top' and 'Reset order'. Both should then edit a extra node field timestamp (*remark at the bottom). The checkboxes should not be checked when re-editing the node, since it is more of an action (it's difficult to explain, but I think it should be clear what i'm trying to say)
  4. Have this extra date field available in views

*Remark: I read somewhere you could actually add a field to the node table itself, I think it was with schema_alter hook. If the timestamp is in this table, the query's would be faster then when it's in an axtra table (which would mean an extra join)

edit2: Went for a custom module with views, operations and actions integration. The module is finished, maybe i'll make it public. Does anyone think this might be interesting for others? How does this module uploading work on drupal.org?

  • 2
    Nodequeue/Entityqueue might be an alternative – Clive Aug 27 '14 at 9:35
  • Thanks for the suggestion, but already checked that module out, also to much control then that is needed... – Gregory Aug 27 '14 at 9:37
  • Problem is Drupal doesn't natively have the concept of content weight (because it means different things based on the given context). You'll probably find all existing solutions do more than you strictly need, so if you're not prepared to live with that extra bulk you might have to code this yourself – Clive Aug 27 '14 at 9:39
  • Thats what I was fearing... :) Any idea's on how i'd handle this? – Gregory Aug 27 '14 at 9:49
  • @Gregory - With no fear ;) It really sounds like a very interesting challenge for diving deeper into Drupal. Anyway, I added an answer with an approach you don't need coding for. – leymannx Aug 27 '14 at 10:41
1

You could add a simple checkbox to your content type and call it "sticky" or somewhat. Then you add an attachment to your view, choose position before your default view and let this attachment display only the nodes with "sticky" checked, while you exclude the sticky ones from your default view.

In the second step you can add more logic to the sorting of your sticky nodes inside your view attachment. I really like DraggableViews for such tasks. But maybe that's already too much, then you might simply add another integer field to your content type and let the sticky nodes sort by that.

  • This might work! I'd sort the attachment by updated date then, the main view by post date... Problem is then pagination etc, I only show 6 articles per page and there will probably around 50 with the 'sticky' attribute. I'm not sure if and how I can get my main view and attachement view work together on 'number of items visible' of the view – Gregory Aug 27 '14 at 10:41
  • @Gregory - I see. Yeah, you could limit the items in your attachment, without pagination, to only 3 items maybe. But still when you go to the second page of non-sticky nodes the attachment will stay on top. That's not what you want, right? Haha, but look here: drupal.org/node/1398854 - we can take advantage of a specific block behaviour. I'll update my answer and explain it right now. – leymannx Aug 27 '14 at 11:37
  • @Gregory - Dayum, I misread the link I posted. I thought you could create a Views page with your articles, then add a block with the sticky ones and on the block configuration page somehow limit the display of the sticky block to display only on non-paginated pages. But that seems to be rather tricky if you don't want to use PHP filter for security reasons. Otherwise, look there drupal.stackexchange.com/questions/48819/… – leymannx Aug 27 '14 at 12:00
1

A very easy solution is to add a global flag on the node type. You expose the flag only to admin.

In your view you add the flag as a relationship: Limit results to only those entity flagged by a certain flag. Make sure not to select 'Include only flagged content'. Make sure to select By 'any user'

Add the 'Display flag/unflag link' as a field is optional. It will only display for admin, so no worries.

Then add Sort Criteria: 'Sort by whether entities have or have not been flagged' and slect 'Flagged first'. Move this sort criteria above in the list.

Now all flagged content will be promoted, and still retain post date sorting amongst themselves.

And to include this functionality on the 'Content overview page' just add Administration Views and add the flag as a relationship, field and sort once again.

And of course you will expose the flag on the node view page also.

And for even more functionality you can add a date field on the flag also and use that in views to sort on if you prefer. Flags are now fieldable! To enable that you need to set the flag up with a confirmation form as Link Type. Flags also expose a 'flagged time' to views which can also aid in sorting.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.