Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
The topic list view needs a little icon that will jump to the last post in a topic. I spent some time adding this in the style itself but ran into a problem because the last post column is a compound field. Will likely need to make a views field just for this so it can be added in the right spot in views itself.
Michelle
Comment | File | Size | Author |
---|---|---|---|
#13 | advanced_forum_last_post.patch | 7.29 KB | Ingumsky |
#10 | af_lastpost.jpg | 27.4 KB | dunx |
Comments
Comment #1
friolator CreditAttribution: friolator commentedhi Michelle - any progress on this?
Comment #2
MichelleNope. Haven't had much time for my modules in August. Working on getting the bugs out first before adding new features so I can release another alpha.
Michelle
Comment #3
friolator CreditAttribution: friolator commentedno sweat - we'll either put this off until version 1.1 of our site, or I'll put together some kind of ugly hack to make it work in the interim.
thanks!
Comment #4
MichelleComment #5
snupy CreditAttribution: snupy commented+1 I join request. It really would be useful!
Comment #6
__Sander__ CreditAttribution: __Sander__ commentedMay be FIRST unread could work better?
http://drupal.org/node/999196
Comment #7
MichelleThere's already a link to the first unread. This is specifically for jumping to the last post in a topic, which is useful if you aren't logged in and are trying to follow a long discussion over multiple visits. Jumping to the last post and scrolling up a bit is easier than starting at the top and going down.
Michelle
Comment #8
dunx CreditAttribution: dunx commentedVery interested in this myself as it's a standard forum feature currently missing in AF.
Just in case this moves forward, be aware of the pagination issue for nodecomments I raised http://drupal.org/node/1402522
I may have to do some heavy lifting in the meantime to address this for my own use case.
Comment #9
dunx CreditAttribution: dunx commentedOkay, I have this working by adding a new views field handler based on the existing one in AF for the topic pager. It means some additions to your generic MYMODULE.module, a new hander file and some changes to the existing advanced_forum_topic_list view configuration. No hacks/AF/core modifications required. Works fine with multiple pages too (but do see note above in #8).
I'm not going to explain how, but just go through what I did. I don't know if it's 100%, but it works for the use case I have. More than happy for it to end up in AF if Michelle (or whoever holds that golden keyboard these day) wants it there.
It includes some options you can use to decide what the link should be: Field label / short teaser / short teaser + full teaser title. I didn't go as far as adding a fields for "how short", so that's hard-coded.
First, here are the additional functions required for MYMODULE.module
Then you need the handler, which will live in the same root directory as MYMODULE.module and is called
MYMODULE_handler_field_node_last_post.inc
Now you have all the files, it's probably worth clearing the cache! I seem to doing this all the time during dev.
Then you'll need to tweak that view
http://example.com/admin/build/views/edit/advanced_forum_topic_list
First, add a new field. Click the +, filter Groups by Node and you'll see a new "Node: Last topic post link" item. Check that and Add. You can then configure that field, but by default you'll see the link on your topic list from "Last topic post link". Click Update.
You'll need to re-order the fields, so this new field comes before "Node: Last comment author" and "Node: Last comment time". Click the re-order button next to the + next to Fields and drag it up to above Last comment author.
Then you can restyle the output. Click on the gear next to Style: Forum topic list. Then in the Column drop down next to "Last topic post link", select "Last post"; that's the column it will display the field in.
That's about it for the basics. You can play around with the Style option about, to make any field in that view a little different and also use CSS to works its magic too.
I thought this was going to be easy until I worked out that I was going to have to get my hands dirty with handlers, but it only took a few hours and now I'm confident I can do something similar again if I need to, so it's always worth trying to understand a little of the code above, rather than just cut'n'paste. All part of the rich Drupal experience. Good luck.
Comment #10
dunx CreditAttribution: dunx commentedHere's a blurry screen shot to show the new link to last post. Note, nothing is shown if there are no replies.
Comment #11
MichelleSetting this to "needs review" though it's not actually a patch. If you are able to create a patch, that would make this a lot easier to review.
Thanks!
Michelle
Comment #12
Ingumsky CreditAttribution: Ingumsky commentedThanks dunx. I'll try your solution.
Comment #13
Ingumsky CreditAttribution: Ingumsky commentedOK. I've finally tested it. Thank you dunx - it really works.
I tested it on my latest 6.x-2.x-dev install. I added lines needed to advanced_forum.module, /includes/theme.inc, /includes/views/advanced_forum.views.inc and created /includes/views/advanced_forum_handler_field_node_last_post.inc. The code was written by dunx in general but I made some improvements to it. First of all it seems to me that dunx uses node comment module and that's why some of the display options for the field didn't work for me at first. I rewrote his ...short_teaser function to make it possible to use its code with drupal built-in comments. And I changed display modes slightly by adding two more choices to its options list.
You can find my patch attached to this comment. If you want to roll it, place it to your custom modules directory and then type:
cd path/to/your/website/htdocs/directory/sites/all/modules
patch -p0 < advanced_forum_last_post.patch
Then clear your site cache and change the view as dunx mentioned in his #9 post.
Please review and test this code. Hopefully it will be added to the next advanced_forum release.
Comment #14
dunx CreditAttribution: dunx commentedThanks for patchifying Ingumsky. I'll have a play later as your tweaks sound sensible. Can I add "Drupal Developer" to my CV yet? :)
Comment #15
Ingumsky CreditAttribution: Ingumsky commentedYes, you most definitely can :)
Comment #16
mcdruidThank dunx and Ingumsky.
I'd like to get this into beta1 which we're hoping to release soon.
However, in order to do that we'd need to update the default view definition well as adding the new handler and the other stuff that's in the patch (which I've not read, I'm just assuming the view definition is not being patched as you mention updating the view through the UI).
Ingumsky - assigning this to you - let me me know if you need any help with updating the view (or anything else).
Comment #17
Ingumsky CreditAttribution: Ingumsky commentedOK. Thanks mate. I'll change default view in a day or two.