Not signed in (Sign In)

Categories

Vanilla 1.1.5 is a product of Lussumo. More Information: Documentation, Community Support.

Help keep Vanilla free:
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorlukeb
    • CommentTimeJul 9th 2006
     # 1
    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
    •  
      CommentAuthorBergamot
    • CommentTimeJul 9th 2006 edited
     # 2
    Ok, I had a look, and those tags are all immediately echoed in the menu.php theme file.

    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)
    •  
      CommentAuthorlukeb
    • CommentTimeJul 9th 2006
     # 3
    Thanks for taking the time to make an informed reply, Bergamont.

    Your suggestion makes sense, and to a degree that's what I have done. However won't that make updating a problem? Because I can't replace/modify the Menu class with an extension - it has to be done by manually editing the Vanilla.Control.Menu.php file as you say.
    •  
      CommentAuthorBergamot
    • CommentTimeJul 9th 2006
     # 4
    Actually, unless I'm mistaken, you *can* replace the Vanilla.Control.Menu class in an extension without modifying the Vanilla.Control.Menu.php file.
    •  
      CommentAuthorlukeb
    • CommentTimeJul 9th 2006 edited
     # 5
    How do you do that? (specifically the render function under the Menu class)
    •  
      CommentAuthorBergamot
    • CommentTimeJul 9th 2006 edited
     # 6
    This is where I tend to get a little fuzzy, so I'll leave it for someone else to fill in the fine details, but I think the basic idea is that you create a new class that inherits from Menu, overwrite the render function, create an instance of the class, and set $Menu to point to that new object.

    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.
    •  
      CommentAuthorlukeb
    • CommentTimeJul 9th 2006 edited
     # 7
    Whoh, sounds complex.

    Anyone have any idea how to do this?

    (edit: I think I may have it..)
    •  
      CommentAuthorlukeb
    • CommentTimeJul 9th 2006
     # 8
    Thanks for your help Bergamot - It's all working now :D
    • CommentAuthorjakob_r
    • CommentTimeJul 10th 2006
     # 9
    Hey luke, care to share your solution? I'm sure others would find it useful.
    •  
      CommentAuthorlukeb
    • CommentTimeJul 10th 2006 edited
     # 10
    Well, jakob_r, I wish I could format it better but here's the relevant part of default.php:


    //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']);
    }
    }
    •  
      CommentAuthorBergamot
    • CommentTimeJul 10th 2006
     # 11
    Rockin'
Add your comments
    Username Password
  • Format comments as