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.

adding a page that lives in Extensions, but acts like vanilla

ithcyithcy New
edited January 2007 in Vanilla 1.0 Help
i'm trying to build an extension for 0.9.3+ that will be a completely new vanilla page. i want it to have the header, topmenu, sidebar, footer, etc. but i want to keep it all inside its own Extensions folder for maintenance purposes. i understand how to add a tab that links to a new page. but is it possible to make that page stay inside the Extensions folder, yet act like vanilla? i'm probably not making this clear. i want something like the discussions or categories page with my own content.


  • You just need the right includes. Check out the pagemanager extension (if it works for you...or even if it doesnt) to give you some ideas.
  • yeah, i looked at it. that extension, as far as i can tell, modifies settings.php. it doesn't create a brand new top-level page, which is what i want. i know it's a matter of includes, but the thing is, which ones? =)
  • edited February 2006
    I think you could probably get away with including head.php, menu.php, panel.php, foot.php, and page_end.php from the themes/vanilla/templates folder.
  • ithcyithcy New
    edited February 2006
    ah i think i'm on my way

    if (!@$Context) { include_once("../../appg/settings.php"); include_once("../../appg/init_vanilla.php"); }

    along with bergamot's suggestions, it might work. thanks guys.
  • You sure it doesnt create whole new pages ithcy? Werd up!
    p.s. is your name meant to be spelt wrong? whats the story?
  • i'm not entirely sure, as it doesn't work, but from a quick look at the code that's what i am guessing.

    but i'm having much more luck just looking at categories.php and discussions.php, which is what i should have done in the first place.

    weren't you on o8 when i was there? my name was itchy, and i quit for a while, and lentil started a petition thread to get me to come back, but she spelt it 'bring back ithcy' by mistake, and so when i came back i called myself ithcy as a joke and i kept it.
  • i know, fascinating, right?
  • MarkMark Vanilla Staff
    Actually, ithcy, I've created a page in the root of Vanilla for a purpose like this one, except it includes the panel, check it out: If you want to make a completely custom page and keep it within it's own extension folder, just check out that extension.php file to get a good idea for how to include controls within the page - it's a very simple "blank" example.
  • ^^Ok, do that instead :D
  • thanks mark, that helped a lot =D
    i'm really close to having it done already.

    but about this line:
    // 2. BUILD PAGE CONTROLS $ExtensionPage = $Context->ObjectFactory->CreateControl($Context, 'Filler', 'extension_page.php');

    it appears to be pulling the filler content ("This page can be used by extension authors...") from themes/vanilla/templates/extension_page.php

    i just want to create the filler inside my extension. Can i invoke CreateControl() in that way? i know i need to make $ExtensionPage in such a way that AddRenderControl() and FireEvents() know what to do with it.
  • Oh. Cant say i remember that but my memory is appauling. Mark - did you ever get those o8 archives online (i remember you planning something like that..somewhen)?
  • MarkMark Vanilla Staff
    Can't explain right now - about to run out the door.

    But basically you'll have to create your own custom control and use that instead of the Filler control. As long as your page sends a PostBackAction and only displays if that action is found in the querystring, the extensionpage control will not reveal itself.
  • MarkMark Vanilla Staff
    For example, check this out: and now this
  • Postbacks are about my least favorite part of server-scripting.
  • this is giving me a headache

    i made a custom control
    class FTPList extends Control { function Render() { $FileList = "Blah"; $this->Context->Writer->Write($FileList); } }

    instantiate it and add it to Page:
    $FTPList = $Context->ObjectFactory->NewContextObject($Context, "FTPList"); $Page->AddRenderControl($FTPList, $Configuration['CONTROL_POSITION_BODY_ITEM']);

    along with all the head, menu, panel, etc. controls
    and fire the page events

    which gives me a nicely formed vanilla page but the body contains this error:
    Fatal error: Call to a member function on a non-object in /home/stabbe2/public_html/sm/extensions/FilesTab/default.php on line 89

    and line 89 is up there at the top: $this->Context->Writer->Write($FileList);

  • MarkMark Vanilla Staff
    edited February 2006
    That's because you haven't defined the constructor for your control, so it doesn't know what the context is.

    Add this to your control:

    function FTPList(&$Context) { $this->Name = 'FTPList'; $this->Control($Context); }
  • MarkMark Vanilla Staff
    You should also change your render method so that it relies on a postbackaction in order to render. That way it won't conflict with other controls on the page:

    function Render() { if ($this->PostBackAction == 'FTPList') { $FileList = "Blah"; $this->Context->Writer->Write($FileList); } }

    And finally, you don't need to use the Writer to write your control. That class is actually deprecated in 0.9.3 since it was just extra work for the server and never really used in the way I had imagined it. So...

    function Render() { if ($this->PostBackAction == 'FTPList') { $FileList = "Blah"; echo($FileList); } }
  • i had just sort of figured that out.... realized i was reading 0.9.2 docs and found some similar advice you had given to someone else in another thread.

    so now i've got
    class FTPList extends Control { function FTPList(&$Context) { $this->Name = 'FTPList'; $this->Control($Context); } function Render() { if ($this->PostBackAction == 'FTPList') { $FileList = "Blah"; echo($FileList); } } } $FTPList = $Context->ObjectFactory->NewContextObject($Context, "FTPList"); $Page->AddRenderControl($Head, $Configuration['CONTROL_POSITION_HEAD']); $Page->AddRenderControl($Menu, $Configuration['CONTROL_POSITION_MENU']); $Page->AddRenderControl($Panel, $Configuration['CONTROL_POSITION_PANEL']); $Page->AddRenderControl($FTPList, $Configuration['CONTROL_POSITION_BODY_ITEM']); $Page->AddRenderControl($Foot, $Configuration['CONTROL_POSITION_FOOT']); $Page->AddRenderControl($PageEnd, $Configuration['CONTROL_POSITION_PAGE_END']); $Page->FireEvents();

    and what it does:
    shows me the discussions page.

    argh again.
    thanks for your help, mark.
  • i also changed the tab to point to extensions/FilesTab/default.php?PostBackAction=FTPList

    just in case
  • MarkMark Vanilla Staff
    There's only one reason I can think of why it would redirect you to the discussion page, and that is if you don't have permission to view the page in question.

    Can you post the entire contents of your file?
This discussion has been closed.