News:

Wondering if this will always be free?  See why free is better.

Main Menu

Posts in Alphabetical Order

Started by ariescapes, May 12, 2013, 04:45:14 AM

Previous topic - Next topic

ariescapes


A second thread! *trying to solve many problems*

I've been researching this without luck. Now, I have a forum that has only certain boards that are in alphabetical order, and some that are not. We do not have a MOD installed and would like to avoid adding one in because of potential conflicts with the already coded forum.

The problem is, the alphabetical ordered forums was done by 3 tech admin's ago. I have no idea where to find the location that would help me add another forum or two into the list of forums I want the threads as alphabetical. (I found somewhere to find a file that is named "/jquery.js" ... but with the updated 2.0xx forums there doesn't seem to be any such file.)

I've spent two days just ctrl-f files trying to find it. Please help?

Kindred

Wait... POSTS in alphabetical order or BOARDS?

Boards are easy - go to admin > forum > boards and move the board order around as you see fit.
http://wiki.simplemachines.org/smf/Boards

posts are more difficult and would require a mod.
http://custom.simplemachines.org/mods/index.php?mod=3198
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

MrPhil

Terminology first. A forum is the whole thing. It is divided up into one or more categories. Each category contains one or more boards. Each board has one or more topics. Categories can be arranged in arbitrary order (alphabetically or by functional area) in Admin. Boards can be arranged in arbitrary order in Admin. Topics are arranged by last update (except "pinned" topics). What are you trying to do? If it's to arrange categories and/or boards in alphabetical order, you would edit them in the Admin section.

kat

I'm not sure, either, what you, actually, want.

But, for what it's worth, look at this page:

http://www.simplemachines.org/community/index.php?board=147.0

Then, look at this one:

http://www.simplemachines.org/community/index.php?board=147.0;sort=subject;desc

Same page, but the subjects are sorted, alphabetically.

You can achieve that by clicking on "Subject", at the top.

Arantor

Oh, and sorting by alphabetic is much slower than using any other option. Just something to bear in mind.

ariescapes

Sorry, not boards, posts. 2 am talking.

I -know- there is a mod. It is the easy answer. I don't want to use the mod to put posts in specific boards in order because there has already been a previous modification. I don't want to have any conflict between the two.

"Subject" clicking to put it in answer works but not for all users, and mostly for personal preference. I want it to be a forum/board standard for posts to be in order.

Arantor

Then you're stuck. Because the only way to do this is to use a mod, and the mod suggested is probably the best for the job.

ariescapes

Well, that doesn't help me find and remove the code already in place. It's somewhere, and it works. I just don't know where it is.

Arantor

It's likely in Sources/MessageIndex.php but could have other traces elsewhere.

Personally I'd download everything on the site and run something like WinMerge to compare it to a master copy of SMF 2.0.4 to see what's different.

ariescapes

I have done something like that (compared and searched -every file- over and over). These forums have been manually chopped in many places so the code is pretty ... haphazard.

I'm open to other suggestions, i do want to avoid using the mod as much as I can.

Arantor

That's why you use WinMerge, it will let you see every file that's changed and show you the difference between the two.

But seriously, there is no way to have a board be (and stay) in alphabetic order without some kind of mod.

ariescapes

Quote from: Arantor on May 12, 2013, 12:20:12 PM
But seriously, there is no way to have a board be (and stay) in alphabetic order without some kind of mod.

I would agree with you on this one, except there is no mod on these forums and i have 3 boards that have posts in alphabetical order.

Arantor

Then you have a mod, or you posted in alphabetical order.

I know this for a fact because in the SMF installation I have, I had to specifically add the code because SMF didn't have the option for it.

ariescapes


Is there someone else with a different option, because there is a 3rd option and it is where I need the help finding.

I respect that you believe it is only those two options. There is no mod installed. And with multiple posts by multiple people on various dates to all be in alphabetical order in designated boards, yeah, these were not posted in alphabetical order, they are sorted that way. It was an edit done many many install/upgrades previous and somehow translated over and is still in effect.

Arantor

-sigh- I guess I'll have to *prove* it to you then. Here is the relevant segment from an unmodified MessageIndex.php that determines order. Lines 284 onwards.

// Default sort methods.
$sort_methods = array(
'subject' => 'mf.subject',
'starter' => 'IFNULL(memf.real_name, mf.poster_name)',
'last_poster' => 'IFNULL(meml.real_name, ml.poster_name)',
'replies' => 't.num_replies',
'views' => 't.num_views',
'first_post' => 't.id_topic',
'last_post' => 't.id_last_msg'
);

// They didn't pick one, default to by last post descending.
if (!isset($_REQUEST['sort']) || !isset($sort_methods[$_REQUEST['sort']]))
{
$context['sort_by'] = 'last_post';
$_REQUEST['sort'] = 'id_last_msg';
$ascending = isset($_REQUEST['asc']);
}
// Otherwise default to ascending.
else
{
$context['sort_by'] = $_REQUEST['sort'];
$_REQUEST['sort'] = $sort_methods[$_REQUEST['sort']];
$ascending = !isset($_REQUEST['desc']);
}

$context['sort_direction'] = $ascending ? 'up' : 'down';


$sort_methods lists all the possible methods MessageIndex knows about. One of which, first_post, isn't even an option in the UI anywhere.

If neither is specified in the URL or the one specified in the URL is not known, it resets to last_post, which causes it to sort by the last message in each topic and forces it to be descending (i.e. ascending = false)

Otherwise it looks at what was put in the URL.

Then a short piece later, line 334 onwards, is the actual query that gets some data.

$request = $smcFunc['db_query']('', '
SELECT t.id_topic
FROM {db_prefix}topics AS t' . ($context['sort_by'] === 'last_poster' ? '
INNER JOIN {db_prefix}messages AS ml ON (ml.id_msg = t.id_last_msg)' : (in_array($context['sort_by'], array('starter', 'subject')) ? '
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)' : '')) . ($context['sort_by'] === 'starter' ? '
LEFT JOIN {db_prefix}members AS memf ON (memf.id_member = mf.id_member)' : '') . ($context['sort_by'] === 'last_poster' ? '
LEFT JOIN {db_prefix}members AS meml ON (meml.id_member = ml.id_member)' : '') . '
WHERE t.id_board = {int:current_board}' . (!$modSettings['postmod_active'] || $context['can_approve_posts'] ? '' : '
AND (t.approved = {int:is_approved}' . ($user_info['is_guest'] ? '' : ' OR t.id_member_started = {int:current_member}') . ')') . '
ORDER BY ' . (!empty($modSettings['enableStickyTopics']) ? 'is_sticky' . ($fake_ascending ? '' : ' DESC') . ', ' : '') . $_REQUEST['sort'] . ($ascending ? '' : ' DESC') . '
LIMIT {int:start}, {int:maxindex}',
array(
'current_board' => $board,
'current_member' => $user_info['id'],
'is_approved' => 1,
'id_member_guest' => 0,
'start' => $start,
'maxindex' => $maxindex,
)
);


The way this works is to get the list of just topic ids (because it's faster to get just the ids, *then* get all the data, than to do it all in one hit mostly due to MySQL's sorting precedence when it comes to text columns)

As you can see it's reusing the variable set up in the prior code block, and it's sorting by is_sticky (1 = sticky, 0 = not sticky) then sorting by the parameter set up.

So, I am telling you, you have a modified form of SMF because IT CANNOT DO WHAT YOU BELIEVE IT CAN. That's the out of the box code in 2.0.4, it simply does not do what you are telling me it is - because it cannot.

QuoteIt was an edit done many many install/upgrades previous and somehow translated over and is still in effect.

So you DO HAVE a mod installed. A mod is no more than a find/replace operation on the code, just bundled up into a convenient package.

There are only two choices here: unmodified code or modified code. So you have a mod (short for modification of code) in there of some kind.

I can't tell you what is modified because I haven't got your code, but I'm telling you that the only way you're going to find out how to alter it is to compare the files to a fresh set, like I already set.

As for anyone else with a different option, the answer would be no. I'm not being funny but I know SMF better than almost anyone else.

ariescapes

Fine, yes, there is a modification of the code. That is obvious or i wouldn't have the problem I am having in the first place. It is not from some package, and after research to the type of modification it was done in the .js -somewhere-. Installing a/the packaged modified code into the already modified board creates a conflict in the code for those forums and could essentially give me errors.

My problem is finding that modification in the code. I have looked and looked so I came here hoping to find a solution. MessageIndex.php would have been handy and useful if that code was there, but it isn't. It doesn't seem to be on any of the php, unless i'm looking for the wrong piece of code. Based on what I have, it looks the same as your provided unmodificated code. Meaning, its somewhere else.

Arantor

So do as has been suggested now: download all your files, compare them using a tool like WinMerge to see what's physically changed compared to the master code.

There are something like 110,000 lines of code in SMF across 5 different computer languages. As you've found it's like a needle in a haystack so use the tools already suggested that are designed for that sort of job.

ariescapes

Seems like the only solution. I do appreciate the help, so don't get me wrong. Communicating over text can be just as confusing. :)

Its just such a frustrating problem..

Kindred

and this is why you should either use pre-packaged mods - or keep a detailed log of the manual modifications that you make to the code
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

ariescapes

I'm the third tech on this site, I didn't install it. The first tech was incompetent with logs, and hacked up everything.

Advertisement: