Users running a non-download version of Vanilla (pulled from github), on branch release/2019.016 or master from the last 2 weeks should upgrade to release/2019.017 or latest master for security reasons. Downloaded official open sources releases are not affected.

Filter discussion by Name

How can I filter discussions by Name using existing Models?

Tagged:

Comments

  • R_JR_J Cheerleader & Troubleshooter Munich Moderator

    Neither the DiscussionModel nor the model implement the like() method from the SQL driver which would allow filtering by names. But the SQL driver is accessible through the DiscussionModel. Therefore you can do it like that:


           $discussionModel = DiscussionModel::instance();
           $discussionModel->SQL->like('Name', '%test%');
           $discussions = $discussionModel->get(0, 10);
           foreach($discussions as $discussion) {
               echo $discussion->Name.'<br>';
           }
    


    This way you directly add the "like" to the query builder before the get() method starts doing its work. 😉


  • Thanks a lot!

  • rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one" NY ✭✭✭

    See the FilterDiscussion plugin and specifically at the LK parameter.

Sign In or Register to comment.