Okay, I am not a programmer by trade and can't get a clue to where to look and the other guy working with me is a prgrammer but has very little free time, we were wondering if it would be possible to change the coding for TP to allow articles to be sorted by date, I was nearly certain I had seen a thread with the information i need but could not find it again with the search function.
Any help on where/ what to change would be very welcome. We use SMF 1.0.7, btw.
This will be possible in the next release of TinyPortal.
It is in some ways implented in Tp.v086 to, but dont work all that well, but in the next you will have a lot more ways of show the articles, hour/Day/month/year/ featured, splitted on the frontpage and more
For a priview on how it can look, visit my site and frontpage where it is divided in several columns and those can be sorted by date and so on.
Familjegodis (http://www.familjegodis.se/forum)
Yeah, i am particularly looking forward to the work you guys have been doing for the next releases and have read the implemented and expected features for the next versions too. What I thought is whether it would be possible or not to change the code to allow all articles to be sorted alphabetically instea dof by date.
I don't need to change it any further after that, or give choices for the user, for that i can wait the release of the next versions. Thanks for the quick reply though G6.
I let Bloc answer what code to change, he is the developer of Tp so i guess he can give you the best answer :)
It wont be possible to sort them alphabetically in the next release though, but maybe in future release :)
Okay, I have a couple of suggestions for the articles and downloads that I will be posting to the appropriate place later, but I still have to comapre them with the forthcoming additions to TP and see if they are not inside those. And praises to the team behind the mod and site, i can't thank you enough for dedicating your time to our benefit. :D
I thought they were sorted by date in the first place
I had made a post about that, having some more custom over article settings
as I currrently set the dates ahead of time, to keep the article to the front
who looks as the date anyways when its right infront of you ( the article )
Well, having the site with a lot of articles, like our is (http://againsttheshadow.org/), I have more 50 articles to approve and sorting them by date means finding will be harder and changing their dates to have the ordeer work would be a pain. I know there will be an increase in the articles and how it works with future releases, but I was wondering if it would be possible to hard code the sorting order into some file and how, we want to ahve them alphabetically.
We wil eventually find an answer to this, but having some guidelines from those mkore used to TP would be better than having to find out on our own in the very first week of using SMF and TP.
Its possible to change the sorting order, this will be a feature in v1.0. But you can hardcode it. Open TPortal.php and find this code:
if($mycat!='')
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE art.category=$mycat AND art.off=0 AND art.approved=1 AND art.authorID=mem.ID_MEMBER ORDER BY art.date DESC LIMIT $start,$max", __FILE__, __LINE__);
and change to:
if($mycat!='')
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE art.category=$mycat AND art.off=0 AND art.approved=1 AND art.authorID=mem.ID_MEMBER ORDER BY art.subject ASC LIMIT $start,$max", __FILE__, __LINE__);
and find this code:
function tpsort($a, $b)
{
return strnatcasecmp($b["timestamp"], $a["timestamp"]);
}
and change to:
function tpsort($a, $b)
{
return strnatcasecmp($b["subject"], $a["subject"]);
}
Let me know if this works, as I just quickly put this together. ;)
Thanks a lot Bloc and G6, TP rocks and we look forward to the coming versions, I will make some suggestions soon enough, though i trust most of them are either implanted or on the to do list I do not want to refrain from giving feedback to what i like and can be made better. :D
Nice work on this mod and on support, all of you, I have read quite a few threads and G6 is everywhere, and so are you, as time allows. :)
Quote from: Bloc on August 10, 2006, 05:07:08 PM
Its possible to change the sorting order, this will be a feature in v1.0. But you can hardcode it. Open TPortal.php and find this code:
if($mycat!='')
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE art.category=$mycat AND art.off=0 AND art.approved=1 AND art.authorID=mem.ID_MEMBER ORDER BY art.date DESC LIMIT $start,$max", __FILE__, __LINE__);
and change to:
if($mycat!='')
$request = db_query("SELECT art.*, mem.realName FROM ({$tp_prefix}articles AS art, {$db_prefix}members AS mem) WHERE art.category=$mycat AND art.off=0 AND art.approved=1 AND art.authorID=mem.ID_MEMBER ORDER BY art.subject ASC LIMIT $start,$max", __FILE__, __LINE__);
I am not certain that the code is the same you got from memory, the one I found on the file was this one:
if($mycat!='')
$request = db_query("SELECT * FROM {$tp_prefix}articles WHERE category=$mycat AND off=0 AND approved=1 ORDER BY date DESC", __FILE__, __LINE__);
elseif($mypage!='')
$request = db_query("SELECT * FROM {$tp_prefix}articles WHERE id=$mypage AND off=0 AND approved=1 LIMIT 1", __FILE__, __LINE__);
else
$request = db_query("SELECT * FROM {$tp_prefix}articles WHERE frontpage=1 AND off=0 AND approved=1 ORDER BY date DESC", __FILE__, __LINE__);Should I change that instead, and so, how? The other one is perfectly fine though, so it must be the amount of codes you have memorized there, can't blame you, lots of versions and redoing. :D
ah, yes. I forgot...that code was from 0.9.5, while you have 0.8.6. :)
Just switch "ORDER BY date DESC" to "ORDER BY subject ASC" and it should work fine. The second "tpsort" should be the same.
Thanks a lot Bloc, I knew this could be done somehow without hours looking for where and how. ;)
It worked like a charm, now I will leave you guys to your hard and great work. Since I just found this amazing forum, should this be taken to tips and tricks? ;)
it should be merged with my topic :(
Well, has it helped you too? My site has this done and working. ;)
nope
gave up on 1.0.7 cause no one was making mods for it
so I went up to 1.1 RC2 and re did my entire site
so I lost everything that I had for the new features
( I think it was worth it )
I jsut noticed, after quite a while, that this change lead to a change in the way news items are shown in the frontpage, they also get sorted alphabetically, but in reverse (from Z to A), a very unwelcome side effect of the change that resulted in me going back to the original code.
We will be installing SMF 1.0.8 and Tp 0.9.5 in the weekend and hopefully we will have things perfect with that alone. ;)
Just thought you woudl like to know. Cheers!
Thats because the sorting routine sort the other way too..and it does sort both topics and articles. So although articles is fetched correctly, the topics are not - because it use a SSI function, which is already "made".
Thanks for the reply Bloc, is that changed on v0.9.5 or in the thoughts for v1.0? If not, I would suggest giving us options to sort articles and still have the enws items sorted the way they should be, I think it could be useful to more people that way, but if it involves too much work i can udnedrstand it not being done at all.
I do want to congratulate you on your work though, it is very very good. :D
Thank you. :)
I will look into this. I can see it as viable option, along with for example showing news, then articles or vice-versa. Also a mode where articles, news and recent uploads come mixed or after one another.
It would be interesting to have sucha feature, it could be as simple as marking an upload or article as news item on the user end too, since featured has different traits to it.
As soon as we get v0.9.5 running and I get familiar with it I plan to post some ideeas for new features for your (and your team) consideration, I hope to help with good ideas and feedback, what i see as the best way to give you praises for your work, aiming to make it better. :)