Is there a way to automatically embed links on the recent discussion page?

edited February 2016 in Feedback

Via the https://vanillaforums.org/addon/example-plugin, I can show excerpts at the discussion board and with a small adjustment in the plugin (credits to @clethrill) even HTML code works. But is there a way that YT and other links also automatically changes in the excerpts like in the real post.

Hope you understand, what I try to explain.

Thank you.

Comments

  • LincLinc Director of Development Detroit Vanilla Staff

    You probably want to pass the text thru Gdn_Format::html() before outputting it.

  • Thank you @Linc, I found it because the direction you pointed me to.

    I changed class.example.plugin.php line 192

    echo wrap(sliceString(strip_tags($Sender->EventArguments['Discussion']->Body),$TrimSize), 'div', array(

    to

    echo wrap(sliceString(Gdn_Format::html($Sender->EventArguments['Discussion']->Body,$TrimSize->Discussion->Format)), 'div', array(

    R_Jhgtonight
  • Can someone please point to me, how I can do the EXACT thing but in the categories?

    If you click now on the category page, you will see the list of discussions of that certain category. But without the excerpts. I tried to change the example plugin above, but don't know which controller I need. I assume, it's something in the following part.

    public function discussionsController_afterDiscussionTitle_handler($Sender) {

        $TrimSize = c('Plugin.Discussionexcerpt.TrimSize', 1000000000);
    
        $RenderCondition = c('Plugin.Discussionexcerpt.RenderCondition', 'all');
    
        $Type = (val('Announce', $Sender->EventArguments['Discussion']) == '1') ? "announcement" : "discussion";
        $CompareType = $Type.'s';
    
        if ($RenderCondition == "all" || $CompareType == $RenderCondition) {
    
            echo wrap(sliceString(Gdn_Format::html($Sender->EventArguments['Discussion']->Body),$TrimSize->Discussion->Format), 'div', array(
                'class'  => "DiscussionexcerptDescription"
            ));
        }
    }
    

    Thank you!

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    public function CategoriesController_afterDiscussionTitle_handler($Sender) {

  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    or maybe

    public function CategoryController_afterDiscussionTitle_handler($Sender) {

  • @vrijvlinder thank you very much!!! It's the first one:

    public function CategoriesController_afterDiscussionTitle_handler($Sender) {

  • edited March 2016

    Edit: uploading to the addons section

    Notice: This plugin is not written by me, I just throw it in all together and trying not to mess up. It is based on the example plugin of the Vanilla staff and with help from @clethrill , @Linc & @vrijvlinder

    vrijvlinder
  • vrijvlindervrijvlinder Papillon-Sauvage MVP

    You need to upload those into the add ons section... because they need to follow the guidelines...

  • Oh ic.. Shall I delete my previous post than?

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2016

    Just delete the zip files by hitting the x upon edit post on the files. then go to the addons section and upload the new plugins :pleased:

    https://vanillaforums.org/addon/add

  • @vrijvlinder what does this mean?

    /class.Categoryexcerpt.plugin.php: The addon's key is not the same as its folder name.

  • vrijvlindervrijvlinder Papillon-Sauvage MVP
    edited March 2016

    Here is example of how it must be, name of plugin must be the same as folder name of plugin.

    $PluginInfo['nameofplugin'] = array(
       'Name' => 'nameofplugin',//must match folder name both of those
       'Description' => 'your description of plugin',
       'Version' => 'yourversion',
       'SettingsUrl' => 'if any',
       'SettingsPermission' => 'if any', 
       'License'=>"GNU GPL2",//must add license 
       'Author' => "Name of author"
    );
    
Sign In or Register to comment.