Board Default Sort

Started by Anguz, October 05, 2004, 09:52:23 PM

Previous topic - Next topic

Anguz

Link to Mod

This mod allows you to set a different topic sorting for a board than the forum's default. It also sticks for the session, custom sorting a visitor does.
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

I don't know if it's just me but it won't work on RC1 (blank white screen on all forums, instead of the forums).

Is this a RC2 only feature?  If so is there anyway to make one for RC1.. I've customised RC1 so much I don't know if it's possible for me to upgrade and I really need this feature.

Anguz

In the mod's page it's specified it's for RC2. I had not tried it with RC1. It is possible to make it work, but I haven't looked into it, so I'm not sure how much it'd need to be changed. I'll check it out and post here.
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine


Anguz

For RC1, try this. Extract the mod files from the archive do the following changes in a text editor:


<edit file>
modification.xml
</edit file>

<search for>
<search position="before"><![CDATA[b.boardOrder, b.countPosts, b.memberGroups, b.ID_THEME, b.override_theme,
]]></search>
</search for>

<replace>
<search position="before"><![CDATA[b.ID_THEME, b.override_theme,
]]></search>
</replace>


All the other steps of the mod should go in without errors in RC1. Let me know how it goes.

Re-package the files, it can be .tar.gz or .zip (just the files, not the folder with the files).
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

It says this when I go to install it:

Execute Modification     ./Themes/default/MessageIndex.template.php     Failure

Any idea why? The file is chmodded to 777 correct .. all the rest of the files are a success.

Anguz

It should work fine with an unmodified RC1 copy of that file. Perhaps one of your modifications is affecting the installation. Could you paste inside code tags the block between

// Are there actually any topics to show?


and

// Show a "select all" box for quick moderation?


please?
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

Here we go:

if (!empty($context['topics']))
{
echo '
<td width="9%" colspan="2"></td>
<td><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="14%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="22%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>';

Anguz

That's odd, it should apply the modification fine. Oh well, you can do it by hand. Use this:

if (!empty($context['topics']))
{
echo '
<td width="9%" colspan="2">', ($context['sort_default'] ? '<a href="' . $scripturl . '?board=' . $context['current_board'] . '.' . $context['start'] . ';sort=default">' . $txt['sort_default'] . '</a>' : ''), '</td>
<td><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : ';asc', '">', $txt[70], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="14%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=starter', $context['sort_by'] == 'starter' && $context['sort_direction'] == 'up' ? ';desc' : ';asc', '">', $txt[109], $context['sort_by'] == 'starter' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=replies', $context['sort_by'] == 'replies' && $context['sort_direction'] == 'up' ? ';desc' : ';asc', '">', $txt[110], $context['sort_by'] == 'replies' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="4%" align="center"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=views', $context['sort_by'] == 'views' && $context['sort_direction'] == 'up' ? ';desc' : ';asc', '">', $txt[301], $context['sort_by'] == 'views' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>
<td width="22%"><a href="', $scripturl, '?board=', $context['current_board'], '.', $context['start'], ';sort=last_post', $context['sort_by'] == 'last_post' && $context['sort_direction'] == 'up' ? ';desc' : ';asc', '">', $txt[111], $context['sort_by'] == 'last_post' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" border="0" />' : '', '</a></td>';
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

Hmm.. still doesn't work.. I make the change to the MessageIndex file by hand and proceed with the other changes on the other files.. but it just shows up a blank page as well.

It might not work well with the custom changes I've done.

Basically all I want this mod for is to sort a specific board by "First post  . . . Time the topic's first message was posted." -- just for the boardNews forum the SSI is pulling from.

Anguz

Then read this topic in Tips and Tricks:

http://www.simplemachines.org/community/index.php?topic=16514.0

In [Unknown]'s code, just change 'subject' to 'first_post' and put the ID for the board you are referring to where he wrote BOARD ID HERE!!.

Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

How do I make it so newest topics are on the top though rather then at the bottom?

Anguz

Try this:

if ($board == BOARD ID HERE!!)
{
if (!isset($_REQUEST['sort']))
$_REQUEST['sort'] = 'first_post';
if (!isset($_REQUEST['desc']))
$_REQUEST['asc'] = '';
}
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

I wanted something like this:

if ($board == 38)
{
if (!isset($_REQUEST['sort']))
$_REQUEST['sort'] = 'first_post';
if (!isset($_REQUEST['asc']))
$_REQUEST['desc'] = '';
}


But yeah as you can see easy fix ;) Works excellent, thanks!! :)

Anguz

Great :)

BTW, that will always sort your board desc, is that what you want? You have the problem that links to sort asc in the MessageIndex template don't have the asc value in the URL, it was assumed. So you need to add that ;asc part when it's not ;desc.
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

Yeah it'll need to always be sorted like that.  It's the only board that does really, just want it sorted so newest at the top down to oldest at the bottom.

Thanks again, you helped out big time :)

Anguz

#16
I know you want it sorted like that by default, what I mean is that even if someone clicks on the column headers, it won't be sorted asc, always desc.

if (!isset($_REQUEST['asc']))
$_REQUEST['desc'] = '';


If there's no asc or desc in the url, it'll be desc. If there's a desc, it'll be desc. Only with an asc in the url it'll be asc. The problem is that the urls don't have the asc at the end in the default theme's template. What I'm saying is that you have to add them if you ever want it be sorted asc.

Just find the five ? ';desc' : '', in MessageIndex.template.php and change them to ? ';desc' : ';asc',.

When you upgrade your forum, it'll be way easier for you to install the mod to manage this. ;)
Cristián Lávaque http://cristianlavaque.com

ADoomedMarine

Ahh ok now I see.. I'll get that fixed up now.

Thanks for that.  :D

Anguz

#18
Updated the mod  to 1.21

There was a problem with uninstallation where some modifications weren't reverted.

The default sorting link was still showing in some cases when it wasn't necessary.
Cristián Lávaque http://cristianlavaque.com

Armada

I applied this mod about a week and a half ago (SMF 1.0 RC2) and it worked great,the users were very impressed with it -  BUT then I suddenly noticed today that it wan't working. Aaaarrgghh.

Over the last two days I've:
Applied the "php Vulnerability" patch to my RC2
Optimized the database in the admin section of SMF

I think the vulnerability patch alters load.php and search.php - coeld it be this Sort Mod has been wiped out in part by the vulnerabilty patch (or perhaps I've done something else wrong)

Thanks,
Trystan
--- SMF Rocks even more than YabbSE---

Advertisement: