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 html to php pages

edited August 2007 in Vanilla 1.0 Help
Hi as some of you probably know by now i'm trying to turn my forum into a website. Well i'm able to make new custom php pages that have all the features of the regular pages (like the sidebar and tabs, add-ons, etc.) but I can't figure out how to customize the body of the page in html. Here is one of my custom pages I have made. Note this is still in very early testing phase so if Im going about this all wrong please let me know lol: <?php /* * Copyright 2003 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: Display and manipulate discussions */ include("appg/settings.php"); $Configuration['SELF_URL'] = 'Anime_Junction.php'; include("appg/init_vanilla.php"); // 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE // Ensure the user is allowed to view this page $Context->Session->Check($Context); if (!$Configuration["USE_CATEGORIES"]) header("location:".GetUrl($Configuration, "index.php")); // Define properties of the page controls that are specific to this page $Head->BodyId = 'CategoryPage'; $Menu->CurrentTab = "anime_junction"; $Panel->CssClass = "CategoryPanel"; $Panel->BodyCssClass = "Categories"; $Context->PageTitle = $Context->GetDefinition("Categories"); // 2. BUILD PAGE CONTROLS // Add the category list to the body $CategoryList = $Context->ObjectFactory->CreateControl($Context, "CategoryList"); // 3. ADD CONTROLS TO THE PAGE $Page->AddRenderControl($Head, $Configuration["CONTROL_POSITION_HEAD"]); $Page->AddRenderControl($Menu, $Configuration["CONTROL_POSITION_MENU"]); $Page->AddRenderControl($Panel, $Configuration["CONTROL_POSITION_PANEL"]); $Page->AddRenderControl($NoticeCollector, $Configuration['CONTROL_POSITION_NOTICES']); $Page->AddRenderControl($CategoryList, $Configuration["CONTROL_POSITION_BODY_ITEM"]); $Page->AddRenderControl($Foot, $Configuration["CONTROL_POSITION_FOOT"]); $Page->AddRenderControl($PageEnd, $Configuration["CONTROL_POSITION_PAGE_END"]); // 4. FIRE PAGE EVENTS $Page->FireEvents(); ?> and this is the type of html I'd like to have in it: <tr> <td class=\'maintitle\' colspan="2"><center>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/1/1.html">#</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/A/A.html">A</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/B/B.html">B</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/C/C.html">C</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/D/D.html">D</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/E/E.html">E</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/F/F.html">F</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/G/G.html">G</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/H/H.html">H</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/I/I.html">I</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/J/J.html">J</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/K/K.html">K</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/L/L.html">L</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/M/M.html">M</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/N/N.html">N</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/O/O.html">O</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/P/P.html">P</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/Q/Q.html">Q</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/R/R.html">R</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/S/S.html">S</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/T/T.html">T</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/U/U.html">U</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/V/V.html">V</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/W/W.html">W</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/X/X.html">X</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/Y/Y.html">Y</a>  <a href="http://oga.mmorpgnut.com/Anime_Junction/Anime_Reviews/Z/Z.html">Z</a> </center> </td> </tr> <tr> <td class="post1" width="5%" valign="top" style="padding:5px">Anime Reviews from A-Z. If you would like to submit your own review for an anime that currently isn\'t on this list, please email it to Crazyotaku@mchsi.com. Below are what you need for the review: <p />·Picture from the anime (preferribly not too big, but not too small, if you need a reference just check a current review pic on this site.) <br />·Summary of anime <br />·Year it was released in japan or the US <br />·Number of episodes <br />·Type: Movie, OVA, TV. <br />·Company that released it <br />·Any other information you feel is neccessary </td> </tr> </table>
«13

Comments

  • ithcyithcy New
    edited August 2006
    (fixed)

    // 2. BUILD PAGE CONTROLS // Add the custom HTML to the body class BodyContent { function BodyContent(&$Context) { $this->Context = &$Context; } function Render() { $html = "<table>etc</table>"; echo($html); } } $BodyContent = $Context->ObjectFactory->NewContextObject($Context, 'BodyContent'); // 3. ADD CONTROLS TO THE PAGE $Page->AddRenderControl($Head, $Configuration["CONTROL_POSITION_HEAD"]); $Page->AddRenderControl($Menu, $Configuration["CONTROL_POSITION_MENU"]); $Page->AddRenderControl($Panel, $Configuration["CONTROL_POSITION_PANEL"]); $Page->AddRenderControl($NoticeCollector, $Configuration['CONTROL_POSITION_NOTICES']); $Page->AddRenderControl($BodyContent, $Configuration["CONTROL_POSITION_BODY_ITEM"]); $Page->AddRenderControl($Foot, $Configuration["CONTROL_POSITION_FOOT"]); $Page->AddRenderControl($PageEnd, $Configuration["CONTROL_POSITION_PAGE_END"]);
  • edited August 2006
    ah thank you very much, as you can see i am a php newbie lol. EDIT: hmm i tried your exact code there and I got this error in the body of the page: Fatal error: Call to a member function on a non-object in /mounted-storage/home4/sub002/sc11923-BRUP/oga/Vanilla.1.0.1/library/Framework/Framework.Class.Page.php on line 71 So I went to check out line 71 on the Framework.Class.Page.php file and it has this in it: function WriteControls($Controls) { // Loop through the controls and write them if (is_array($Controls)) { ksort($Controls); while (list($key, $Control) = each($Controls)) { $Control->Render(); } } } $Control->Render(); is line 71 do I need to add $BodyContent in here somewhere?
  • ithcyithcy New
    edited August 2006
    i just came back to this thread because i realized i told you the wrong way to do it :)

    $BodyContent needs to be an object, not a string. (It's been a while since i've done this)
    try this:class BodyContent { function BodyContent(&$Context) { $this->Context = &$Context; } function Render() { $html = "<table>etc</table>"; echo($html); } } $BodyContent = $Context->ObjectFactory->NewContextObject($Context, 'BodyContent');
  • Thank you thank you, now I can start making this into a website. :D
  • don't thank me until you're sure it works this time :)
  • I did test it when i replied.. lol. I should be able to pound out some templates so I can mass produce the custom pages. ^.^
  • you might also take a look at the Page Manager extension...
  • I think that's what he's using mate.
  • not according to the code at the top of the page...
  • I am using the page manager extension, but it creates new tabs and keeps each page in one php file, i need them to be totally seperate when I create custom pages, so I am just using that to make new tabs which will be used as the website "sections" and then my own custom pages to be applied to each tabbed section. So it will be like this: you click on a tab called Anime Junction and see a page displaying links to anime reviews, then you click on one and bring up a new page still under the anime junction tab. Get the picture now? ^.^
  • yep
  • And now I have another problem.. lol. Ok I got the adding custom pages with html thing working just fine, but now I can't get my custom tabs from the PageMng extension to show up on my custom pages. >< They show up fine on the forum, but whenever I go to a custom page that isn't in the PageMng, the custom tabs go away. Anyone know if there's a way to fix this? Here is my custom page code if that helps: <?php /* * Copyright 2003 Mark O'Sullivan * This file is part of Vanilla. * Vanilla is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. * Vanilla is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with Vanilla; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * The latest source code for Vanilla is available at www.lussumo.com * Contact Mark O'Sullivan at mark [at] lussumo [dot] com * * Description: Display and manipulate discussions */ include("../../../appg/settings.php"); $Configuration['SELF_URL'] = '1.php'; include("../../../appg/init_vanilla.php"); // 1. DEFINE VARIABLES AND PROPERTIES SPECIFIC TO THIS PAGE // Ensure the user is allowed to view this page $Context->Session->Check($Context); if (!$Configuration["USE_CATEGORIES"]) header("location:".GetUrl($Configuration, "index.php")); // Define properties of the page controls that are specific to this page $Head->BodyId = 'CategoryPage'; $Menu->CurrentTab = "anime_junction"; $Panel->CssClass = "CategoryPanel"; $Panel->BodyCssClass = "Categories"; $Context->PageTitle = $Context->GetDefinition("1"); // 2. BUILD PAGE CONTROLS // Add the custom HTML to the body class BodyContent { function BodyContent(&$Context) { $this->Context = &$Context; } function Render() { $html = '<table><center>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/1/1.php">#</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/A/A.php">A</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/B/B.php">B</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/C/C.php">C</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/D/D.php">D</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/E/E.php">E</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/F/F.php">F</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/G/G.php">G</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/H/H.php">H</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/I/I.php">I</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/J/J.php">J</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/K/K.php">K</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/L/L.php">L</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/M/M.php">M</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/N/N.php">N</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/O/O.php">O</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/P/P.php">P</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/Q/Q.php">Q</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/R/R.php">R</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/S/S.php">S</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/T/T.php">T</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/U/U.php">U</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/V/V.php">V</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/W/W.php">W</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/X/X.php">X</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/Y/Y.php">Y</a>  <a href="http://oga.mmorpgnut.com/Vanilla.1.0.1/Anime_Junction/Anime_Reviews/Z/Z.php">Z</a> </center> <p><center># Reviews <p>.hack//sign <br>.hack//Legend of The Twilight</center></table>'; echo($html); } } $BodyContent = $Context->ObjectFactory->NewContextObject($Context, 'BodyContent'); // 3. ADD CONTROLS TO THE PAGE $Page->AddRenderControl($Head, $Configuration["CONTROL_POSITION_HEAD"]); $Page->AddRenderControl($Menu, $Configuration["CONTROL_POSITION_MENU"]); $Page->AddRenderControl($Panel, $Configuration["CONTROL_POSITION_PANEL"]); $Page->AddRenderControl($NoticeCollector, $Configuration['CONTROL_POSITION_NOTICES']); $Page->AddRenderControl($BodyContent, $Configuration["CONTROL_POSITION_BODY_ITEM"]); $Page->AddRenderControl($Foot, $Configuration["CONTROL_POSITION_FOOT"]); $Page->AddRenderControl($PageEnd, $Configuration["CONTROL_POSITION_PAGE_END"]); // 4. FIRE PAGE EVENTS $Page->FireEvents(); ?>
  • I can't add anything to this discussion, but I do have another question please .....

    I have a HTML website with a Vanilla forum attached. I use Google Analytics (which requires insertion of some HTML code) to count visitors to the website, but haven't been able to count how many visit the forum (not many so far!). Does this thread provide a way of doing that, by adding HTML to the Vanilla index page? If so, can someone just explain a little more what I need to do please, or refer me to a website that outlines the code needed? Sorry, but I know nothing about coding except what I pick up on forums like this.
  • edited September 2006
    Is it not a script to add in the header?
    If so, you just need to make an extension:
    $Head->AddString("<script>...</script>");
    or $Head->AddScript("http://url/to/the/script");
  • Sorry Dinoboff, but which file(s) should I add that to? Can the HTML between the script tags be anything?
  • It was just a guess I don't know how Google Analytics work.
    What do you need to add in your pages and where in the pages?
  • edited September 2006
    I check on google:
    ... $Configuration['GoogleAnalyticsAccountNumber'] = 'xxxx-x'; //add an array of pages to not analyse if ( !in_array($Context->SelfUrl, array('settings.php')) ) { $Head->AddScript("http://www.google-analytics.com/urchin.js"); $Head->AddString(" _uacct=\"UA-".$Configuration['GoogleAnalyticsAccountNumber']."\"; urchinTracker(); "); }
  • I'm sorry, Dinoboff, I'm not just not sure what I should try.

    To answer your earlier question, the Google Analytics code is a simple few lines of HTML, inserted just above the tag in any HTML page:


    _uacct = "xxxxxxxxx"; urchinTracker();

    This slightly different to your listing, though seems to contain the same elements. But I guess that is just detail.

    So my real problems are:

    (1) Which file(s) should I insert this code into? There is the same header on most (all?) pages, so I guess the file which controls the header - is that Common.Controls.php? Any others?

    (2) What identification or tags or whatever do I need to include (I am OK on HTML & CSS but know no PHP)? ithcy had "function ...." and you suggested "Addstring".

    Of course I could try, but I thought it best to try to clarify a little first. (I've had too many disasters in the past by experimenting!) :)
  • ithcyithcy New
    edited September 2006
    just make yourself an add-on with dinoboff's code. it's simple to do.
    1. make a new folder inside the extensions folder.
    2. create a blank textfile and save it as "default.php" inside that folder.
    3. paste the following into it:
    <?php /* Extension Name: Google Analytics Extension Url: http://lussumo.com/community/discussion/3507/ Description: Adds google analytics code to your vanilla forum pages. Version: 1.0 Author: ercatli Author Url: http://lussumo.com/community/account/1973/ */ //replace this with your google analytics account number, of course $Configuration['GoogleAnalyticsAccountNumber'] = 'xxxx-x'; //add an array of pages to not analyse if ( !in_array($Context->SelfUrl, array('settings.php')) ) { $Head->AddScript("http://www.google-analytics.com/urchin.js"); $Head->AddString("<script type=\"text/javascript\">; _uacct=\"UA-".$Configuration['GoogleAnalyticsAccountNumber']."\"; urchinTracker(); </script>"); } ?>

    save it, upload it, enable it. that should be all.
  • edited September 2006
    like ithcy said
This discussion has been closed.