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.
Noob needs Extension Writing Help
Hey Guys.
I really like Vanilla, and have skinned my forum for it already. However, the first time round was a hack-job, where I just edited the code directly as need be. I've decided that won't be satisfactory though, because I'd like to be able to update my forum regularly, so begun my venture in Extension Development.
Apart from some basic stylesheet changes, my only real changes have been:
* Adding my own header with navigation to the top of every page (other than people.php)
* Removing the 'Header' div
* Moving (and changing the format) of the tabs from the 'Header' div, into the 'Panel' div
The first challenge I overcame relatively easily, by creating and rendering a new class extended from control.
However, the second two are a little bit more intensive. That is, because now I have to move/remove/modify sections of the code. For example, taking out the 'Header' div, or changing the formatting of the tabs. I'm really stumped now, and have no idea where to go from here. I'd really appreciate it if you guys could share a little bit of your wisdom with me, because I'm sure someone knows how to do this!
Thanks in advance,
Luke
0
This discussion has been closed.
Comments
You certainly could replace Vanilla.Control.Menu.php with your own custom control that ignores the menu.php theme file, and doesn't render the Header div. All that would be left then is to add the menu options to the panel, and style it.
If you're planning to make even more element-rearranging changes in the future, I would consider making a custom theme instead.
(edited for accuracy)
The problem is, I'm a little unclear as to whether, by the time your extension is loaded, it may be to late to do this.
//To Add Banner class rootnav extends Control { function rootnav(&$Context) { $this->Name = 'rootnav'; $this->Control($Context); } function Render() { $this->CallDelegate('PreRender'); echo "...banner html..."; $this->CallDelegate('PostRender'); } } if (!in_array($Context->SelfUrl, array("people.php"))) { $rootnav = $Context->ObjectFactory->CreateControl($Context, 'rootnav'); $Page->AddRenderControl($rootnav, $Configuration['CONTROL_POSITION_HEAD'] + 1); }
//To Modify 'Menu' class if (!in_array($Context->SelfUrl, array("people.php"))) { class Menu_rev extends Menu { function Render() { ksort($this->Tabs); $this->CallDelegate('PreRender'); include(ThemeFilePath($this->Context->Configuration, '../extensions/_extensiondirectory_/menu.php')); //Revised menu.php will be called for Rendering $this->CallDelegate('PostRender'); } } $Menu_rev = $Context->ObjectFactory->CreateControl($Context, 'Menu_rev'); //create an instance of Menu_rev(ised) $Menu =& $Menu_rev; //I had to reload the Tabs, so the following code is copied from the appropriate section off 'appg/init_vanilla.php' // Cleaner suggestions welcome! // BUILD THE MAIN MENU $Menu_rev->AddTab($Context->GetDefinition('Discussions'), 'discussions', GetUrl($Configuration, './'), '', $Configuration['TAB_POSITION_DISCUSSIONS']); ... $Menu_rev->AddTab($Context->GetDefinition('Account'), 'account', GetUrl($Configuration, 'account.php'), '', $Configuration['TAB_POSITION_ACCOUNT']); } }