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.
Options

Stupid #1

KrakKrak New
edited October 2005 in Vanilla 1.0 Help
Im trying to make an extension to add a header accross the top of the forum. I got the header file to be displayed and I got it to be rendered in the body tag. But the number 1 keeps popping up underneath it. How do I get rid of this 1? It only puts the "1" when I use include("header.php"); if I put all of the html from the header file into the extension file then the 1 doesnt show up. I'd rather keep the header in its own file, making it easy to modify, but if I cant, I guess I can always just slap it in the actual extension file (last resort). I don't know if I did the extension right, I read some of the docu and got this far. Heh, its working so far. Any ideas? ============================= class HdrPage extends Control { function Render() { # $this->Context->Writer->Write("blaha!"); $this->Context->Writer->Write(include("header.php")); } } $HdrPage = $Context->ObjectFactory->NewContextObject($Context, "HdrPage"); $Page->AddControl("Menu_Render", $HdrPage); ============================= the header.php include causes the 1, if i use <div class=\"HdrPage\">gsdgsdg</div> then there is no 1.

Comments

  • Options
    NickENickE New
    edited October 2005
    Search the complete html output for an odd one, chances are it's outside a tag it shouldn't be (eg. inside a <table> while outside the <tr>). Or it might be a misplaced one somewhere in header.php that's being outputted. Was that html you used taken from header.php or from that generated by header.php? Excuse my ignorance if I'm mistaken, but as I couldn't find header.php in the default Vanilla installation, maybe it would help to post that if it's your creation.
  • Options
    KrakKrak New
    edited October 2005
    The header.php file is for my extension. I have HeaderPage.php (the extension file), and header.php (the file with the actual header stuff for the extension).

    The only thing in the header.php file is 4 div tags and some text "this is the header file" stuff like that. There is no "1" on any of the pages I am using, so I dont know where its from or why it is there.

    The 1 is being generated right after the header.php output and right before the rest of the normal Vanilla stuff.

    header file
    HeaderPage extension file
  • Options
    Oh, I see what's wrong. Unless the included file specifically returns a value, include() returns 1 to indicate a successful include, and FALSE to indicate a failure. As header.php does not return anything, include() returns 1 which is appended onto the string. You can fix this by adding in the line: <?php return ''; ?> at the end of your header.php file.
  • Options
    Ah it worked, most excellent. Many thanks!
  • Options
    edited October 2005
    Excellent work Krak! Is there anyway for the header to be inserted into <body> rather than above it?
  • Options
    NickENickE New
    edited October 2005
    Yes.
    class BodyHeader
    {
    	function BodyHeader(&$Context)
    	{
    		$this->Context = &$Context;
    	}
    	
    	function Render()
    	{
    		$this->Context->Writer->Write('Your header here');
    	}
    }
    
    $BodyHeader = $Context->ObjectFactory->NewContextObject($Context, 'BodyHeader');
    $Body->AddControl($BodyHeader);
    
    ...or something of that sort. Haven't tried it yet, but the concept's still there.

    EDIT: If you want I can add an administration panel to it. Just a little something so the admin can input the header to display.
  • Options
    Won't this all be obsolete when the new template system comes around with the next rev?
  • Options
    edited October 2005
    I just had a quick try with it and it doesn't seem to work - then again it's late and i'm not really paying attention. To be honest the admin panel isn't a problem. Ulimitatly what i want to do is somthing like the following: <div id="container"> <div id="header"></div> <div id="menu"><!-- unordered list tabbed menu --></div> <div id="sidebar"><!-- might be a sidebar --></div> <div id="content"><!-- Vanilla --></div> <div id="footer"></div> </div> But i'm a designer not a developer very good xhtml, css and some php + sql but not enough to get my head around this at present (mostly due to lack of time). In any case i can get close enough to what i need for the site with just the header and footer, container would be nice but not absolutely essentail as Vanilla's CSS is good enough for me to achieve the same effect by editing rather than throwing in lots of potentailly conflicting code. Planet Tolkien is in essence on giant fourm (5k Members and 120,000 posts to date) so i just need to get in the navigation which will allow the blog area, writers guild and content sections; which this header extention would go a long way to doing.
  • Options
    [Won't this all be obsolete when the new template system comes around with the next rev?] Quite possiblly yes but i don't know what kind of timeline Mark is on for that - though given the size or PT Mark has advised i wait for it but in the meantime i'm trying to get a devlopment version together so the eight moderators who run the fourms can get used to vanilla and how the new site might operate so they will be able to FAQ it and help out the members.
This discussion has been closed.