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 all comments except the first one in reverse order?

This discussion is related to the NillaBlog addon.
ddumontddumont ✭✭
edited February 2011 in Vanilla 2.0 - 2.8
@Todd @Tim @Mark ?

Can you offer any suggestions on how/where I might plug in to do this?

There was an error rendering this rich post.


  • You mean sorting like in Voting plugin here but in reverse order?
  • mmmm... not quite like the voting plugin. The voting plugin will sort answers with votes up top and then regular comments below.

    I want the initial post comment at the top (the blog post) and then the most recent comments displayed first. So reverse sort order from normal except for the 1st post that started the thread.

    There was an error rendering this rich post.

  • Have you tried it? The initial post is in another table so will probably will be shown first and then the rest of the posts. If not, we have to see the PHP / SQL that blongs to the posts/ discussions

    There was an error rendering this rich post.

  • Interesting... No, I haven't looked into the SQL yet or changing the sorting yet.
    Just musing while I'm here at work.

    If you have an idea and are interested, I'd welcome patches/pull requests/etc on the project page. :)

    There was an error rendering this rich post.

  • @ddumont
    Install voting plugin, change sorting via locale and add "desc" to corresponding SQL query. Or make your own plugin with thsi change from original.
  • MarkMark Vanilla Staff
    edited February 2011
    Try this:
    public function CommentModel_BeforeGet_Handler($Sender) {
    $Sender->OrderBy(array('c.DateInserted', 'asc'));
  • @Mark THANKS! I'll try it out. Also, what plugin are you using for code formatting?

    There was an error rendering this rich post.

  • MarkMark Vanilla Staff
    Also, be sure to turn on the debugger plugin so you can see all of the queries run on each page to make sure that your plugin is doing what it should...
  • Try this:
    public function CommentModel_BeforeGet_Handler($Sender) {
    $Sender->OrderBy(array('c.DateInserted', 'asc'));
    @Mark, as I understand, it do not work with Voting plugin installed.
    Or I am not right here?
  • Thanks again, @Mark

    Do you know if anyone will be able to review my plugin soon? It also looks like since you are using it, the syntax highlighter plugin should probably be marked reviewed, right? :)

    There was an error rendering this rich post.

  • edited February 2011

    Speaking of syntax higlighter.
    @Mark, I hope to see separate Body and Body_Html for all main elements (Conversations, Discussion text and Comment body).
    As having formatters always working upon display is not good thing.
    May be it is also good idea to integrate few plugins inside Vanilla.
    I mean Voting, Tagging Enchanced, Gravatar and this syntax highlighter.
    So, we could merge their CSS files and make code much more efficient.
  • MarkMark Vanilla Staff
    @ddumont - I don't have much time for coding or reviewing anymore. Todd and Tim are spread pretty thin, too. We're getting through things as fast as we can.

    @tester13 - Agreed on the body_html. We've been talking about doing that for a while, and decided to do a memcached implementation first instead.

    The minify plugin was intended to do what you're talking about w/ combining js and css files, but we found limitations in how the minify library worked, as well as problems with combining plugin files on various pages (ie. a plugin only wants to include it's css on one page, not all pages, so it doesn't make sense and might cause problems to have it in a core css file that is included on all pages, and there is no way for the minify plugin to know if the css for that plugin is supposed to be included on just one page, etc).
  • @Mark thanks for all your hard work! I love Vanilla :)

    There was an error rendering this rich post.

  • @Mark Do you think that memcached alone will be better idea, as various plugins seem to use same render on the fly approach? Fo me introducing html version seems faster to implement, especially considering good architecture.

    As for Minify, I don't think that it is good approach, as instead of cashing it actually makes browser fetch different versions of almost same files.
    So, may be better approach is integration of few plugins and automatic making minified versions of main forum CSS and combining plugins in two-three groups by usage (leaving jquery and jquery.ui for CDN).
  • ddumontddumont ✭✭
    edited February 2011
    I tried

    public function CommentModel_BeforeGet_Handler(&$Sender) {
    if ($Sender->EventArguments["CategoryID"] != C("Plugins.NillaBlog.CategoryID"))

    $Sender->OrderBy('c.DateInserted desc');
    but I had to update my pull request because the comment model does not know about the category ID (deal breaker)

    This seems to work on my forum, but posting new comments really screws up the ui... any ideas or is this looking like a lost cause ?

    There was an error rendering this rich post.

  • I already proposed to look at Voting plugin :-)
  • ddumontddumont ✭✭
    edited February 2011
    @tester13 Sorry? I don't follow.
    I want conditional sorting based on what kind of category is being shown.

    Voting plugin uses values in preferences or sent in a get query. My sort needs to be conditional on the category you happen to be looking at.

    Were you talking about that, or something about the post creation and placement in the ui?

    There was an error rendering this rich post.

  • And?
    Look at plugin.
    And use CategoryID for discussion to switch sorting order.
  • @tester13 I'm sorry, are you trying to be an ass?
    The Voting plugin will not meet the needs of my project, if you disagree why don't you actually point me to something useful. I've already looked at the plugin and obviously have missed what you are talking about.

    There was an error rendering this rich post.

Sign In or Register to comment.