Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to add category name to panel?

edited May 2007 in Vanilla 1.0 Help
I want to write something on panel that changes with viewing different category.
I write as a extention like this

if ($Context->SelfUrl == "index.php") { $AddToPannel = ' <h2>'.$CategoryName.' Related</h2>'....; $Panel->AddString($AddToPannel );}
But I don't know how to get category name value.
Could anyone tell me, please?


  • edited May 2007
    If you are viewing a specific category than you can use this

    You should also check whether you are actually viewing a category or not
    so do this
    if ($DiscussionGrid->Category != 0) { $AddToPannel = '<h2>'.$DiscussionGrid->Category->Name.' Related</h2>'; $Panel->AddString($AddToPannel );} }
  • It doesn't work It appear nothing in any page.
  • did u just copy paste it
    there is an extra bracket in my code. take it out
    whats ur complete code
  • edited May 2007
    I want each category has a related link panel.
    The context is from media wiki.
    It's my complete code.
    <?php /* Extension Name: Related Links Extension Url: Description: Using Mediawiki to make a related link panel Version: 0.1 Author: Shenk Author Url: */ if (!defined('IN_VANILLA')) exit(); $Context->Dictionary['RelatedLinks'] = "Related Links"; $WikiURL = "http://myhost/wiki/"; if ($Context->SelfUrl == "index.php") { $LinkInfo = $WikiURL."index.php?title=RelatedLink:".$DiscussionGrid->Category->Name."&action=render&ctype=text/html"; $FileContext = file_get_contents($LinkInfo); $RelatedLinks = ' <h2>'.$Context->GetDefinition('RelatedLinks').'</h2> <div id="RelatedLinks"> '.$FileContext.' </div>'; $Panel->AddString($RelatedLinks); } ?>
  • edited May 2007
    add this
    if ($Context->SelfUrl == "index.php") {
    $DiscussionGrid = $Context->ObjectFactory->CreateControl($Context, 'DiscussionGrid');

    ur link info won't work cause category names can have spaces in them. u can either not include spaces in ur category names or use urlencode()
  • Thank you. It works^^~~~
  • edited May 2007
    btw you should be doing this in Nugget Management extension
  • edited May 2007
    Thank you very much. I didn't figure out this extension can do this before. ^^a.... I'm using this extension to do this function now. ^^~
This discussion has been closed.