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
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>
0
This discussion has been closed.
Comments
// 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"]);
$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');
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.
If so, you just need to make an extension:
$Head->AddString("<script>...</script>");
or
$Head->AddScript("http://url/to/the/script");
What do you need to add in your pages and where in the pages?
... $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(); "); }
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!)
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.