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?
I want to write something on panel that changes with viewing different category.
I write as a extention like this
But I don't know how to get category name value.
Could anyone tell me, please?
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?
0
This discussion has been closed.
Comments
$DiscussionGrid->Category->Name
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 );} }
there is an extra bracket in my code. take it out
whats ur complete code
The context is from media wiki.
It's my complete code.
<?php /* Extension Name: Related Links Extension Url: http://lussumo.com/docs/ Description: Using Mediawiki to make a related link panel Version: 0.1 Author: Shenk Author Url: http://blog.pixnet.net/Shenk */ 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); } ?>
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()