Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Discussion body Before Render a Discussion

edited September 2010 in Vanilla 2.0 - 2.8
Hi there,

Im developing a SEO plugin for vanilla 2. It will add meta tags to the html head. Since the documentation is not too extense I'm not sure if I'm doing things correctly and not sure how to do some things, so this will be a bit long question.

In my theme's "default.master.php", just before the closing head tag I have added:
<?php echo $this->Meta;?>

I've created a plugin that lets me save in the config file a description and some keywords. In the "discussions" I add the data like this:
public function DiscussionsController_Render_Before(&$Sender) { $Description = Gdn::Config('Plugins.NeedSeo.Description', FALSE); $Tags = Gdn::Config('Plugins.NeedSeo.Tags', FALSE); $Sender->Meta = '<meta name="Description" content="'.$Description.'" />'; $Sender->Meta .= '<meta name="Keywords" content="'.$Tags.'" />'; }

This is working correctly, but would like to know if this is a better way to do it. The problem now is with "discussion". I want to add the discussion body to the description meta tag. I think it might be something like:
public function DiscussionController_Render_Before(&$Sender) { $Description = $this->Discussion->Body; $Sender->Meta = '<meta name="Description" content="'.$Description.'" />'; }

This is not working. Does the FireEvent pass this information to the Magic Event? Do I have to load the discussion model and get this data? How woul you do it?

By the way, how can I filter html so it is not shown in the meta tags?

Thank you and sorry for my english, I'm from Barcelona :)

Comments

  • Hello, i just uploaded a plugin that does pretty much the same, except it guesses keywords and description from the Discussion.
    I took a different turn but i think your code may work if you replace $this by $Sender in your public function DiscussionController_Render_Before(&$Sender) {

    My SEO plugin:
    http://vanillaforums.org/addon/611/seocompanion
Sign In or Register to comment.