Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2006-10-23 08:41:30
- hilary
- Member
- Registered: 2006-09-11
- Posts: 37
Sort comments by date ascending
Hi Guys!
So, my boyfriend has had a website forever, and he basically didnt care what went up there, so I’ve started doing a css showcase gallery (just because I like looking at pretty sites! :))
Now, Im using the comments field for submissions, so how do I arrange the comments by date asc so that the most recent addition goes up to the top please?
Heres the unfinished site!
Offline
Re: Sort comments by date ascending
Only possible with a plugin (may not exist yet) because there is no sort attribute for comments (yet). Would be nice to have that in a newer version though.
Offline
#3 2006-10-23 12:52:13
- hilary
- Member
- Registered: 2006-09-11
- Posts: 37
Re: Sort comments by date ascending
(may not exist yet)
Yeah, Im pretty sure theres no plugin for it.. Ive been searching everywhere!
Is it possible to do it using an sql command do you know? (or anyone else), Im totally open to hacking code if its possible!!
Offline
Re: Sort comments by date ascending
If you don’t mind hacking core TXP code, look in taghandlers.php for the comments function. There should be an SQL query in there where you can change the order from ASC to DESC on this line:
http://dev.textpattern.com/browser/development/4.0/textpattern/publish/taghandlers.php#L1517
… or you could copy the comments function into a new plugin (give the function a new name) and use that, so you don’t have to change TXP itself.
Offline
#5 2006-10-23 13:38:40
- hilary
- Member
- Registered: 2006-09-11
- Posts: 37
Re: Sort comments by date ascending
Thanks Ruud! I dont have my files here, but I’ll give that a go after work, I’d be quite familiar with tweaking that page anyway, so hopefully I can do it!
Im going to avoid functions, just because I’ll probably break the thing, so if I can find the sql command, I’ll be happy, I’ll let you know what happens, thanks for your help!
Offline
Re: Sort comments by date ascending
Ok, I tried that
<code>
parentid=’.intval($id).’ and visible=’.VISIBLE.’ order by posted DESC’
</code>
I also tried order by posted date DESC, and I took the extra measure of changing all other asc or desc, into date desc..
No change on the order of the comments so far tho.. :(
…………………
I <3 txp
…………………
Offline
Re: Sort comments by date ascending
Yaaaay!
Success!
Thanks so much Ruud!
In case anyone else needs to do this, go to your taghandlers.php page and do exactly what ruud said above, line 1517, just change asc to desc, dont touch anything else tho, and it works!
Many thanks! :)
…………………
I <3 txp
…………………
Offline
#8 2007-05-11 02:03:59
- chairman
- New Member
- Registered: 2006-07-02
- Posts: 4
Re: Sort comments by date ascending
I’ve been looking a long time for this. I tried it as well and it worked for me. The version of txp I’m using is 4.04.
Offline
Pages: 1