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

Default thread display order

Discussion in 'XenForo Questions and Support' started by xFalcon, Dec 16, 2010.

  1. xFalcon

    xFalcon Member

    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..
     
    faeronsayn likes this.
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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.
     
    faeronsayn likes this.
  3. xFalcon

    xFalcon Member

    That'll change all of my forums though won't it? I just want to do one... :)
    Looks like I can't for now..
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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).
     
    Fuhrmann and xFalcon like this.
  5. xFalcon

    xFalcon Member

    Thank you Jake :D exactly what I was after.
     
  6. BamaStangGuy

    BamaStangGuy Well-Known Member

    How would I sort by thread title ASC?
     
  7. BamaStangGuy

    BamaStangGuy Well-Known Member

    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.
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    That is normal. This template edit only changes the link in the forum listing.
     
  9. BamaStangGuy

    BamaStangGuy Well-Known Member

    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?
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There is no option for that. You would have to modify the code with an addon. You can post a request:

    http://xenforo.com/community/forums/add-on-requests.35/
     
  11. Arty

    Arty Well-Known Member

    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');
        }
    
     
    Bios Element likes this.
  12. Bios Element

    Bios Element Member

    I presume there would be a simple way to apply this to multiple nodes without having a dozen if statements?
     
  13. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    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>
    
     
  14. Arty

    Arty Well-Known Member

    Try in_array():

    if(in_array($forum['node_id'], array(1, 2, 3, 4)))
     

Share This Page