Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Sorting discussions by date

Hello,

I'd like to change my forum to display the discussions by the date the discussion was created and not by its latest reply.

I tried to change config.php and add these lines:

$Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted';
$Configuration['Vanilla']['Discussions']['SortField'] = 'asc';

It did not have the effect that I wanted.

Please advise. Thanks!

«1

Answers

  • Just curious how would people find new discussions then, by paging through all discussion topics. Doesn't seem to optimal the way I am envisioning it, even if you could do it, which I think would require major tweaking in core, or a plugin or application to totally replace things.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • hgtonighthgtonight ∞ · New Moderator
    edited April 2013

    @Ricardo_Viteri What version on Vanilla are you running?

    I believe you want to use:

    $Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted';
    $Configuration['Vanilla']['Discussions']['SortDirection'] = 'desc';
    

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

    peregrinebusinessdadvrijvlindercoKANH
  • @hgtonight, I'm using Version 2.0.18.4

  • Hi @peregrine, most of the discussions are specific to what's going on with the events of the community. Therefore, you could be discussing the same topic in different times. Imagine a monthly conference meeting. Therefore, people have started adding comments to old discussions.

    This is why I would like to keep discussions sorted by date and not by most recent comments.

    peregrineUnderDogShadowdare
  • hgtonighthgtonight ∞ · New Moderator
    edited April 2013

    @Ricardo_Viteri, did my configurations work?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Hi @hgtonight, unfortunately, the configurations did not work.

    Thank you!

  • hgtonighthgtonight ∞ · New Moderator

    Have you modified any core files?

    In /applications/vanilla/models/class.discussionmodel.php, on line 161 should be this:

    $this->EventArguments['SortField'] = C('Vanilla.Discussions.SortField', 'd.DateLastComment');
    $this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');
    $this->EventArguments['Wheres'] = &$Wheres;
    $this->FireEvent('BeforeGet');
    

    Is this there for you?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    @hgtonight

    there is this plugin which reverses comment order. Maybe it can be modified to do that with discussions. Or to show the oldest comments first.

    http://vanillaforums.org/addon/reversecommentsort-plugin

    UnderDog
  • hgtonighthgtonight ∞ · New Moderator
    edited April 2013

    @vrijvlinder Good idea on that plugin. :D

    I looked into it and it deals with the comment model. Turns a discussion into a twitter feed. Or a facebook wall. Whatever. Since it just deals with the comment afterconstruct event, it won't help in this case. :(

    Unfortunately, I can't see why those configurations aren't working. Are you placing them in the /conf/config.php file?

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • I think a little debugging needs to be done. As soon as the changes in http://vanillaforums.org/discussion/comment/180410/#Comment_180410 does not change the sortorder, look in your debug list that is at the bottom of the page, when you turn on the debug modus. Look at the SQL query that's executed. If the sorting there is still different from the changes you made in conf/config.php then those changes are overridden somewhere else. Let's try that first.

    hgtonight
  • I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

    UnderDog
  • edited April 2013

    @hgtonight said:
    Have you modified any core files?

    In /applications/vanilla/models/class.discussionmodel.php, on line 161 should be this:

    $this->EventArguments['SortField'] = C('Vanilla.Discussions.SortField', 'd.DateLastComment');
    $this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');
    $this->EventArguments['Wheres'] = &$Wheres;
    $this->FireEvent('BeforeGet');
    

    Is this there for you?

    This is what I have in line 161:

      $this->EventArguments['SortField'] = C('Vanilla.Discussions.SortField', 'd.DateLastComment');
      $this->EventArguments['SortDirection'] = C('Vanilla.Discussions.SortDirection', 'desc');
        $this->EventArguments['Wheres'] = &$Wheres;
        $this->FireEvent('BeforeGet'); // @see 'BeforeGetCount' for consistency in results vs. counts
    

    It looks like its the same.

  • @hgtonight, I am not looking to sort by the last comment. I am need to sort by the date that the post was created. Would d.DateLastComment be the right parameter?

  • hgtonighthgtonight ∞ · New Moderator

    That is the default that it will load if $Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted'; isn't present in your config.php.

    Could you list out your config.php? Be sure to remove the database info and any other personal info.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • edited April 2013
    // Conversations
    $Configuration['Conversations']['Version'] = '2.0.18.4';
    
    
    // Modules
    $Configuration['Modules']['Vanilla']['Content'] = 'a:6:{i:0;s:13:"MessageModule";i:1;s:7:"Notices";i:2;s:21:"NewConversationModule";i:3;s:19:"NewDiscussionModule";i:4;s:7:"Content";i:5;s:3:"Ads";}';
    $Configuration['Modules']['Conversations']['Content'] = 'a:6:{i:0;s:13:"MessageModule";i:1;s:7:"Notices";i:2;s:21:"NewConversationModule";i:3;s:19:"NewDiscussionModule";i:4;s:7:"Content";i:5;s:3:"Ads";}';
    
    
    // Plugins
    
    // Preferences
    $Configuration['Preferences']['Email']['ActivityComment'] = TRUE;
    $Configuration['Preferences']['Email']['AddedToConversation'] = TRUE;
    $Configuration['Preferences']['Email']['BookmarkComment'] = TRUE;
    $Configuration['Preferences']['Email']['CommentMention'] = TRUE;
    $Configuration['Preferences']['Email']['ConversationMessage'] = TRUE;
    $Configuration['Preferences']['Email']['DiscussionComment'] = TRUE;
    $Configuration['Preferences']['Email']['DiscussionMention'] = TRUE;
    $Configuration['Preferences']['Email']['WallComment'] = TRUE;
    
    // Routes
    $Configuration['Routes']['DefaultController'] = 'a:2:{i:0;s:11:"discussions";i:1;s:8:"Internal";}';
    $Configuration['Routes']['c2l0ZW1hcGluZGV4LnhtbA=='] = 'a:2:{i:0;s:25:"/utility/sitemapindex.xml";i:1;s:8:"Internal";}';
    $Configuration['Routes']['c2l0ZW1hcC0oLisp'] = 'a:2:{i:0;s:19:"/utility/sitemap/$1";i:1;s:8:"Internal";}';
    $Configuration['Routes']['cm9ib3RzLnR4dA=='] = 'a:2:{i:0;s:15:"/utility/robots";i:1;s:8:"Internal";}';
    $Configuration['Routes']['bm90YXNsZWdhbGVz'] = 'a:2:{i:0;s:24:"plugin/page/notaslegales";i:1;s:8:"Internal";}';
    $Configuration['Routes']['ZW5jdWVzdGE='] = 'a:2:{i:0;s:20:"plugin/page/encuesta";i:1;s:8:"Internal";}';
    $Configuration['Routes']['bWlzaW9u'] = 'a:2:{i:0;s:18:"plugin/page/mision";i:1;s:8:"Internal";}';
    $Configuration['Routes']['Y29tb3VzYXJlbGZvcm8='] = 'a:2:{i:0;s:20:"plugin/page/usarforo";i:1;s:8:"Internal";}';
    $Configuration['Routes']['dXN1YXJpb3M='] = 'a:2:{i:0;s:27:"plugin/page/listadeusuarios";i:1;s:8:"Internal";}';
    $Configuration['Routes']['aW50cm8='] = 'a:2:{i:0;s:17:"plugin/page/intro";i:1;s:8:"Internal";}';
    $Configuration['Routes']['aW5mb2JlY2E='] = 'a:2:{i:0;s:20:"plugin/page/infobeca";i:1;s:8:"Internal";}';
    $Configuration['Routes']['ZGlyZWN0b3Jpbw=='] = 'a:2:{i:0;s:18:"plugin/scholarship";i:1;s:8:"Internal";}';
    
    // ThemeOption
    $Configuration['ThemeOption']['Banner'] = '';
    
    // UserList
    $Configuration['UserList']['Limit'] = '16';
    $Configuration['UserList']['Hide'] = FALSE;
    $Configuration['UserList']['Random'] = '1';
    $Configuration['UserList']['Photo'] = '1';
    $Configuration['UserList']['NoPhoto'] = FALSE;
    $Configuration['UserList']['Title'] = '16 miembros de ';
    $Configuration['UserList']['ShowNumUsers'] = '1';
    
    // Vanilla
    $Configuration['Vanilla']['Version'] = '2.0.18.4';
    $Configuration['Vanilla']['Discussion']['SpamCount'] = '3';
    $Configuration['Vanilla']['Discussion']['SpamTime'] = '60';
    $Configuration['Vanilla']['Discussion']['SpamLock'] = '120';
    $Configuration['Vanilla']['Comment']['SpamCount'] = '5';
    $Configuration['Vanilla']['Comment']['SpamTime'] = '60';
    $Configuration['Vanilla']['Comment']['SpamLock'] = '120';
    $Configuration['Vanilla']['Comment']['MaxLength'] = '8000';
    $Configuration['Vanilla']['AdminCheckboxes']['Use'] = TRUE;
    $Configuration['Vanilla']['Categories']['MaxDisplayDepth'] = '3';
    $Configuration['Vanilla']['Categories']['DoHeadings'] = FALSE;
    $Configuration['Vanilla']['Categories']['HideModule'] = FALSE;
    $Configuration['Vanilla']['Discussions']['PerPage'] = '100';
    $Configuration['Vanilla']['Comments']['AutoRefresh'] = '0';
    $Configuration['Vanilla']['Comments']['PerPage'] = '50';
    $Configuration['Vanilla']['Comments']['AutoOffset'] = TRUE;
    $Configuration['Vanilla']['Archive']['Date'] = '';
    $Configuration['Vanilla']['Archive']['Exclude'] = FALSE;
    $Configuration['Vanilla']['Discussions']['SortField'] = 'd.DateInserted'; // by inserting date
    $Configuration['Vanilla']['Discussions']['SortDirection'] = 'desc'; // for ascendign sorting
    
    // Last edited by RicardoViteri ()2013-04-05 00:52:59
  • @UnderDog, how do you turn on debug mode? and where is the log file located?

    Thanks,

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    use < pre > code here < /pre> so it looks better

  • @vrijvlinder, thanks, I was looking for that.

    vrijvlinderUnderDog
  • hgtonighthgtonight ∞ · New Moderator

    @Ricardo_Viteri what view are you wanting to sort? If you don't know, you can just give a sample url.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • you might be using a plugin that changes the sort.

    grep is your friend.

Sign In or Register to comment.