We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

EE hook: comment_entries_comment_format

Development and Programming

Lars Kirchhoff's avatar
Lars Kirchhoff
58 posts
17 years ago
Lars Kirchhoff's avatar Lars Kirchhoff

This question may be related to a resolved thread.

I’ve just looked at the code of the videoplugin extension and noticed that I use the comment_entries_comment_format hook. After playing with the other hook - comment_entries_tagdata - I came to the conclusion, that whenever I use a comment hook. I need to do all the formatting actions within the plugin. In both cases no formatting had been applied. Is that true? Can I call standard functions of the EE framework to do the formatting?

best Lars

       
Robin Sowell's avatar
Robin Sowell
13,160 posts
17 years ago
Robin Sowell's avatar Robin Sowell

From a quick look- don’t see why it should end the regular processing unless you’re using end_script. At least with the tagdata hook. Take a look at the code- if you’re using that extension, should allow you to tweak the tagdata as needed- then send it back with tweaks intact- and allow it to finish just as it would w/no hook. At least in that one. end_script would be a different story- it would just return it when the extension was done doing its thing. Could that be in play?

Also- going to shift to the extensions forum where this is a better fit.

$tagdata = $TMPL->tagdata;
            
            // -------------------------------------------
            // 'comment_entries_tagdata' hook.
            //  - Modify and play with the tagdata before everyone else
            //
                if ($EXT->active_hook('comment_entries_tagdata') === TRUE)
                {
                    $tagdata = $EXT->call_extension('comment_entries_tagdata', $tagdata, $row);
                    if ($EXT->end_script === TRUE) return $tagdata;
                }
       
Lars Kirchhoff's avatar
Lars Kirchhoff
58 posts
17 years ago
Lars Kirchhoff's avatar Lars Kirchhoff

I still have a bit of a problem of understanding the comment_entries_tagdata hook.

$tagdata holds the template for a single comment with all its tags. So I can manipulate the template, add variables or just make it look differently.

$row holds an array with all information about the actual comment.

The function needs to return $tagdata, which means the template data with the template tags. So how do I modify the comment text with this function in order to include the video embed.

I tried the following (I take the row[‘comment’] and do the modifications to the text and then replace the variable in $tagdata, which is then returned):

function renderHTMLCodeComment($tagdata, $row)
{    
    global $TMPL;
        
    $comment = $row['comment'];
    
    // do the modifications
  
    return $TMPL->swap_var_single('comment', $comment, $tagdata);
}

But as I remove the {comment} variable, it isn’t processed anymore and hence no formatting is done anymore.

If I use the comment_entries_comment_format I can modify the comment itself, but no formatting is done afterwards either.

function renderHTMLCodeComment($comment_row)
{    
    $comment = $comment_row['comment'];
    
    // do the modifications
  
    return $comment;
}

So can anyone suggest a solution? How to add the standard formatting to the functions within the extension? Thanks..

best Lars

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.