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 do you find the current CategoryID in a template?
How do you get the current CategoryID inside menu.php or any other template. I want to put a different header on each category page.
0
This discussion has been closed.
Comments
$result = mysql_query("SELECT CategoryID FROM ".$Context->Configuration['DATABASE_TABLE_PREFIX']."Discussion WHERE DiscussionID = '$DiscussionID'",$Context->Database->Connection); $row = mysql_fetch_row($result); $CategoryID = $row[0];
If you have my extension Notifi installed it already grabs that so I think you should be able to just grab $categoryID if it is installed. Try it and let me know
create an extension folder in /extensions and name it as you want, e.g. CustomCategoryHeader.
then create an empty file on it and fill in the metadata for the extension (you can find this info in every other extensions' default.php) remember specially to change the name!
then after the extension's metadata paste this:
function AddCategoryIDToContext(&$DiscussionGrid) { if( isset($DiscussionGrid->Category) ) { $DiscussionGrid->Context->CategoryID = $DiscussionGrid->Category->CategoryID; } } $Context->AddToDelegate('DiscussionGrid','PreDataLoad','AddCategoryIDToContext');
then save the file as default.phpthen in your themes folder, create a new folder (or if you are using any other theme but the default, then in its folder) and copy /themes/menu.php to it.
then add:
if( isset($this->Context->CategoryID) ) { switch($this->Context->CategoryID) { case 1:// echo the html code of the custom category 1 header break; case 2: ... }
login to the forum and go to settings and enable the extension, and hopefully...voilà !