• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Default thread display order

#1
Hi guys,
In one of my sub forums, I want to set the default thread display order to be sorted by "Thread Creation Time", rather than the default "Last Message Time".

Now I know this can be changed when you are viewing the forum itself, by going to the little pop out menu at the bottom - but from what I understand this is setting it for me only. What if I want to make it the default for everyone?

Couldn't find any options for this. Thanks in advance for the replies guys..
 

Jake Bunce

XenForo moderator
Staff member
#2
There is no option for that. But you can fudge it with a template edit:

Admin CP -> Appearance -> Templates -> node_forum_level_2

Replace this code:

Code:
			<h3 class="nodeTitle"><a href="{xen:link forums, $forum}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
...with this:

Code:
			<h3 class="nodeTitle"><a href="{xen:link forums, $forum, 'order=post_date'}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
That will change the links in the forum list to include order=post_date.
 

Jake Bunce

XenForo moderator
Staff member
#4
That'll change all of my forums though won't it? I just want to do one... :)
I like conditionals.

Code:
			<xen:if is="{$forum.node_id} == 2">
				<h3 class="nodeTitle"><a href="{xen:link forums, $forum, 'order=post_date'}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
			<xen:else />
				<h3 class="nodeTitle"><a href="{xen:link forums, $forum}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
			</xen:if>
This will add the order parameter for only the forum specified (node_id 2 in the above code).
 

Brent W

Well-known member
#7
I figured it out, however, this does not work site wide. For example, a user clicking on the forum via the breadcrumb will not have the sort order changed.
 

Brent W

Well-known member
#9
Is there anyway to force this site wide so that when someone opens that forum, regardless of the way they find it (via search engine for example) that it sort by Title ASC?
 

Arty

Well-known member
#11
I was looking for solution to same problem and came up with a different solution that doesn't require adding stuff to forum URL, but it requires changing php code a bit.

Open library/XenForo/ControllerPublic/Forum.php, find function _getDefaultThreadSort and replace contents with something like this:
Code:
    protected function _getDefaultThreadSort(array $forum)
    {
        if($forum['node_id'] == 51)
        {
            return array('post_date',  'desc');
        }
        return array('last_post_date',  'desc');
    }
 

Jake Bunce

XenForo moderator
Staff member
#13
I presume there would be a simple way to apply this to multiple nodes without having a dozen if statements?
Code:
			<xen:if is="in_array({$forum.node_id}, array(1,2,3))">
				<h3 class="nodeTitle"><a href="{xen:link forums, $forum, 'order=post_date'}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
			<xen:else />
				<h3 class="nodeTitle"><a href="{xen:link forums, $forum}" data-description="{xen:if @nodeListDescriptionTooltips, '#nodeDescription-{$forum.node_id}'}">{$forum.title}</a></h3>
			</xen:if>