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 ✭✭✭
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(
            $prefix,
            'span',
            array('class' => 'PrefixDiscussion Sp'.str_replace(' ', '_', $prefix))
        ).$sender->Discussion->Name;

With these lines:

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

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 !

Comments

  • 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!

  • rbrahmsonrbrahmson ✭✭✭
    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
        $sender->setData(
          'Discussion.Name',
          wrap(
            $linkprefix,    /*RB*/
            'span',
            ['class' => 'PrefixDiscussion Sp'.str_replace(' ', '_', $prefix)]
          ).$discussion->Name
        );
    

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

    Good luck

Sign In or Register to comment.