<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Aki&#039;s Blog &#187; Guides</title>
	<atom:link href="http://blog.mangaworld.se/category/guides/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mangaworld.se</link>
	<description>Pretending people care since 2006</description>
	<lastBuildDate>Mon, 30 Aug 2010 14:30:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Creating new pages in Vanilla</title>
		<link>http://blog.mangaworld.se/2010/02/23/creating-new-pages-in-vanilla/</link>
		<comments>http://blog.mangaworld.se/2010/02/23/creating-new-pages-in-vanilla/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 17:32:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[CMS]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Vanilla]]></category>

		<guid isPermaLink="false">http://blog.mangaworld.se/?p=493</guid>
		<description><![CDATA[As with most CMSs, it&#8217;s pretty tough getting into how Vanilla works, but it&#8217;s still my favorite by far, because of its simplicity to use and administrate. It took me some time understanding how to create a brand new PHP page in Vanilla, as it&#8217;s not based on my favorite standard &#8211; having a header.php [...]]]></description>
			<content:encoded><![CDATA[<p>As with most CMSs, it&#8217;s pretty tough getting into how <a href="http://vanillaforums.org">Vanilla</a> works, but it&#8217;s still my favorite by far, because of its simplicity to use and administrate.</p>
<p>It took me some time understanding how to create a brand new PHP page in Vanilla, as it&#8217;s not based on my favorite standard &#8211; having a header.php and a footer.php, the header also including all general functions and styles.</p>
<p>Say for example that you have a Vanilla forum but wants to include a new page about contact information, with the webmaster&#8217;s name and e-mail. With the system Vanilla uses, the first step is to create a new page (lets take for example contact.php).</p>
<pre class="chili"><code class="php""""">

include(&quot;appg/settings.php&quot;);
$Configuration[&#039;SELF_URL&#039;] = &#039;contact.php&#039;;
include(&quot;appg/init_vanilla.php&quot;);

$Context-&gt;Session-&gt;Check($Context);

$Contact = $Context-&gt;ObjectFactory-&gt;CreateControl($Context, &quot;Contact&quot;);

$Page-&gt;AddRenderControl($Head, $Configuration[&#039;CONTROL_POSITION_HEAD&#039;]);
$Page-&gt;AddRenderControl($Menu, $Configuration[&#039;CONTROL_POSITION_MENU&#039;]);
$Page-&gt;AddRenderControl($Panel, $Configuration[&#039;CONTROL_POSITION_PANEL&#039;]);
$Page-&gt;AddRenderControl($Contact, $Configuration[&quot;CONTROL_POSITION_BODY_ITEM&quot;]);
$Page-&gt;AddRenderControl($Foot, $Configuration[&#039;CONTROL_POSITION_FOOT&#039;]);
$Page-&gt;AddRenderControl($PageEnd, $Configuration[&#039;CONTROL_POSITION_PAGE_END&#039;]);

$Page-&gt;FireEvents();

</code></pre>
<p>The lines important here are number 2, 7 and 12, the rest can more or less be the same for any page. The two includes in the beginning call information needed to run the page (appg/settings.php and appg/init_vanilla.php). <em>$Context-&gt;Session-&gt;Check($Context);</em> checks who has the rights to view the page (as an admin of a Vanilla forum you can control if the forums are blocked to non-users, et cetera). The coming line gathers information on which control page to gather further information from. The easiest way is to have this page have the same name as the page itself, in this case <em>Contact</em>. Choosing this name will have the page collect classes from /library/Vanilla.Control.Contact.php, which we have yet to create:</p>
<pre class="chili"><code class="php""""">
class Contact extends Control {
function Render() {
include(ThemeFilePath($this-&gt;Context-&gt;Configuration, &#039;contact.php&#039;));
}
}
</code></pre>
<p>This is really all that needs to be there for a simple page. This class calls the page /themes/contact.php, i.e. the page actually showing the HTML. Vanilla.Control.Contact.php, however, is the page where any PHP for more complex pages should go. If you&#8217;re uncertain on how it works, check some of the premade pages in Vanilla, for example Vanilla.Control.Categories.php.</p>
<p>On to the actual page, themes/contact.php, having the simplest code of all:</p>
<pre class="chili"><code class="php""""">
echo &quot;Howdihoo... the webmaster of this site is Blablabla, with the e-mail spam_me@spam.com.&quot;;
</code></pre>
<p>Easy enough. Let&#8217;s go through it once more:<br />
<strong>/contact.php</strong> calls the actual site, saying it is controlled further by the page Vanilla.Control.Contact.php. It also says that it will use the traditional style with head, menu, panel, foot, and PageEnd, but with the central (between Panel and Foot) being the special &#8220;Contact&#8221;, as presented in Vanilla.Control.Contact.php.</p>
<pre class="chili"><code class="php""""">

include(&quot;appg/settings.php&quot;);
$Configuration[&#039;SELF_URL&#039;] = &#039;contact.php&#039;;
include(&quot;appg/init_vanilla.php&quot;);

$Context-&gt;Session-&gt;Check($Context);

$Contact = $Context-&gt;ObjectFactory-&gt;CreateControl($Context, &quot;Contact&quot;);

$Page-&gt;AddRenderControl($Head, $Configuration[&#039;CONTROL_POSITION_HEAD&#039;]);
$Page-&gt;AddRenderControl($Menu, $Configuration[&#039;CONTROL_POSITION_MENU&#039;]);
$Page-&gt;AddRenderControl($Panel, $Configuration[&#039;CONTROL_POSITION_PANEL&#039;]);
$Page-&gt;AddRenderControl($Contact, $Configuration[&quot;CONTROL_POSITION_BODY_ITEM&quot;]);
$Page-&gt;AddRenderControl($Foot, $Configuration[&#039;CONTROL_POSITION_FOOT&#039;]);
$Page-&gt;AddRenderControl($PageEnd, $Configuration[&#039;CONTROL_POSITION_PAGE_END&#039;]);

$Page-&gt;FireEvents();
</code></pre>
<p><strong>/library/Vanilla.Control.Contact.php</strong>, as already mentioned, presents the class <em>Contact</em>. What it does is in fact to include the page /themes/contact.php.</p>
<pre class="chili"><code class="php""""">
class Contact extends Control {
function Render() {
include(ThemeFilePath($this-&gt;Context-&gt;Configuration, &#039;contact.php&#039;));
}
}
</code></pre>
<p><strong>/themes/contact.php</strong> goes on to showcase the information to be shown visiting /contact.php, here very simply and without any complications, without advanced PHP or MySQL &#8211; that is to be run entirely from the Control page.</p>
<pre class="chili"><code class="php""""">
echo &quot;Howdihoo... the webmaster of this site is Blablabla, with the e-mail spam_me@spam.com.&quot;;
</code></pre>
<p>And you are done. Fix these pages, and if you are to visit /contact.php you will view the text <em>Howdihoo&#8230; the webmaster of this site is Blablabla, with the e-mail spam_me@spam.com.</em>. All of this is simple PHP, yet it took me quite some time to understand, being all new to these types of programming, and I&#8217;m sure others have the same problem. I am very new to writing guides, so if I&#8217;m being unclear please comment or e-mail me.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mangaworld.se/2010/02/23/creating-new-pages-in-vanilla/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
