Advertisement:

Author Topic: Board Default Sort  (Read 48558 times)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Board Default Sort
« on: October 05, 2004, 09:52:23 PM »
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.
« Last Edit: October 05, 2004, 10:46:48 PM by Anguz »
Cristián Lávaque http://cristianlavaque.com

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #1 on: October 06, 2004, 12:45:40 PM »
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.

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #2 on: October 06, 2004, 01:40:06 PM »
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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #3 on: October 06, 2004, 02:10:44 PM »
Thanks :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #4 on: October 06, 2004, 03:35:00 PM »
For RC1, try this. Extract the mod files from the archive do the following changes in a text editor:

Code: [Select]
<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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #5 on: October 06, 2004, 03:49:45 PM »
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.

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #6 on: October 06, 2004, 05:25:15 PM »
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

Code: [Select]
// Are there actually any topics to show?

and

Code: [Select]
// Show a "select all" box for quick moderation?

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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #7 on: October 06, 2004, 11:25:08 PM »
Here we go:

Code: [Select]
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>';

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #8 on: October 06, 2004, 11:41:47 PM »
That's odd, it should apply the modification fine. Oh well, you can do it by hand. Use this:

Code: [Select]
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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #9 on: October 07, 2004, 04:35:38 AM »
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.

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #10 on: October 07, 2004, 06:50:18 PM »
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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #11 on: October 08, 2004, 02:16:22 AM »
How do I make it so newest topics are on the top though rather then at the bottom?

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #12 on: October 08, 2004, 03:43:36 AM »
Try this:

Code: [Select]
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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #13 on: October 08, 2004, 08:04:00 AM »
I wanted something like this:

Code: [Select]
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!! :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #14 on: October 08, 2004, 04:48:02 PM »
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

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #15 on: October 08, 2004, 11:33:56 PM »
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 :)

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #16 on: October 08, 2004, 11:48:11 PM »
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.

Code: [Select]
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. ;)
« Last Edit: October 08, 2004, 11:51:37 PM by Anguz »
Cristián Lávaque http://cristianlavaque.com

Offline ADoomedMarine

  • Semi-Newbie
  • *
  • Posts: 66
Re: Board Default Sort
« Reply #17 on: October 09, 2004, 04:29:59 PM »
Ahh ok now I see.. I'll get that fixed up now.

Thanks for that.  :D

Offline Anguz

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,430
  • Gender: Male
    • cristianlavaque.com
Re: Board Default Sort
« Reply #18 on: October 25, 2004, 07:28:32 PM »
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.
« Last Edit: October 27, 2004, 08:08:48 PM by Anguz »
Cristián Lávaque http://cristianlavaque.com

Offline Armada

  • Jr. Member
  • **
  • Posts: 277
  • Gender: Male
  • Tux loves Linux
Re: Board Default Sort
« Reply #19 on: January 19, 2005, 04:12:34 PM »
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---