HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to: Setting the discussion Prefix to filter on all discussions with the same prefix

rbrahmsonrbrahmson "You may say I'm a dreamer / But I'm not the only one"NY ✭✭✭
edited January 2016 in Feedback

A small change to the PrefixDiscussion plugin by @R_J allows you to set the prefix on the discussion title to link to all discussions with the same filter (using the Filterbyprefix plugin).

In the class.prefixdiscussion.plugin.php plugin find the "discussionController_beforeDiscussionRender_handler" function. Replace the following code:

$sender->Discussion->Name = Wrap(
            array('class' => 'PrefixDiscussion Sp'.str_replace(' ', '_', $prefix))

With these lines:

$linkprefix = anchor($prefix,"/discussions/Filterbyprefix/&filter=".$prefix);
        $sender->Discussion->Name = Wrap(
            array('class' => 'PrefixDiscussion Sp'.str_replace(' ', '_', $prefix))

An artifact of making the prefix a link is that the prefix text appears in blue (like a link) and so if you have stylized the prefixes you may want to change the styles to accommodate the blue links.

Happy New Year !


  • Options
    subdreamersubdreamer San Jose, CA

    Are these changes still relevant? I am using PrefixDiscussion 1.4.0, and I don't see this anywhere. I know the code probably changed since it has been so long. Thank you for your help!

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

    I don't think these changes where actually retrofitted into the plugin but since then a more capable filtering plugin would probably be my choice...

    But, if you are interested I digged an old version of this plugin that was tested on Vanilla 2.6 and you can try it on your hopefully newer Vanilla. The changes in PrefixDiscussion are as follows:

    In the "discussionController_beforeDiscussionRender_handler" function the last lines should be:

    $linkprefix = anchor($prefix,"/discussions/Filterbyprefix/?filter=".$prefix); //RB
            $linkprefix,    /*RB*/
            ['class' => 'PrefixDiscussion Sp'.str_replace(' ', '_', $prefix)]

    Note that the $linkprefix line is different than the one in the old 2015 comment...

    Good luck

Sign In or Register to comment.