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.

Overriding OrderBy

Hi folks,

While building a custom plugin for a client recently, I needed to change the ordering of posts within a category (to use a custom field), which I did via BeforeGet in DiscussionModel - no problem. However, at this point, there is a pre-existing OrderBy set in the SQL object.

Are there any plans to add a way to clear these out (I used reflection to do so, but this isn't really right!) - or perhaps somewhere else I should be looking for (or we should be adding) an event to better achieve this?

Cheers!

UnderDogperegrine

Comments

  • That is a very nice question... If someone can add you to the developers group, the question can be moved to the developers category...

    Maybe @Linc can take a look at your question... Vanilla version is 2.1 right?

    peregrine
  • LincLinc Detroit Admin
    edited June 2014

    It looks like the only way to manually clear SortBy that late is to call the Reset method on the SQL driver to reset the entire query, then rebuild it yourself.

    I think what you want, tho, is Vanilla.Discussions.UserSortField. In your plugin, add this to the instances where you want to override the sort:

    SaveToConfig('Vanilla.Discussions.UserSortField', '{CustomFieldName}', FALSE);

    That should temporarily override the sort order for that single pageload.

    R_JUnderDogperegrineShadowdare
Sign In or Register to comment.