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

This discussion is related to the Filterbyprefix addon.
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(
            $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 !

subdreamer

Comments

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

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

    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

    subdreamer
Sign In or Register to comment.