<?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>SkyBlueCanvas&#187; Creating Menus in SkyBlueCanvas v1.1 &#8211; SkyBlueCanvas</title>
	<atom:link href="http://blog.skybluecanvas.com/tag/menus/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.skybluecanvas.com</link>
	<description>The Lightweight Blog</description>
	<lastBuildDate>Tue, 20 Jul 2010 15:47:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Creating Menus in SkyBlueCanvas v1.1</title>
		<link>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/creating-menus-skybluecanvas-v11/</link>
		<comments>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/creating-menus-skybluecanvas-v11/#comments</comments>
		<pubDate>Thu, 27 Nov 2008 17:58:40 +0000</pubDate>
		<dc:creator>scott</dc:creator>
				<category><![CDATA[Extensions]]></category>
		<category><![CDATA[Fragments]]></category>
		<category><![CDATA[SkyBlueCanvas CMS]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[fragment]]></category>
		<category><![CDATA[fragments]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[menus]]></category>
		<category><![CDATA[pages]]></category>
		<category><![CDATA[skin]]></category>
		<category><![CDATA[skins]]></category>
		<category><![CDATA[skybluecanvas]]></category>
		<category><![CDATA[templates]]></category>
		<category><![CDATA[tutorials]]></category>
		<category><![CDATA[views]]></category>
<category>fragments</category><category>menus</category><category>skins</category><category>tutorials</category>
		<guid isPermaLink="false">http://blog.skybluecanvas.com/?p=53</guid>
		<description><![CDATA[When you create a new page in SkyBlueCanvas, a menu item is already created for you. In fact, there is not really a menu item to create because the system assumes, by default, that if you have created a page, there should be a menu link for. I mean, how else would anyone find your page if there is not link, right?]]></description>
			<content:encoded><![CDATA[<p>When you create a new page in SkyBlueCanvas, a menu item is already created for you. In fact, there is not really a menu item to create because the system assumes, by default, that if you have created a page, there should be a menu link to it. I mean, how else would anyone find your page if there is no link, right?</p>
<p>The only trouble is, which menu should the new page go in? This is where you will have to give SkyBlueCanvas a little help. On the Meta Data tab in the Page Manager (<span class="admin-path">Admin &gt; Pages &gt; Edit</span>), you will see a selector field labeled Menu. You simply select the menu in which you want the page to appear.</p>
<p>There are two logical next questions that you may have. (1) How do I create a new menu? (2) How does the menu get placed on a page? In this article I will answer these two questions.</p>
<p>The answer to question (1), &#8220;How do I create a new menu?&#8221; is very simple. You simply navigate to <span class="admin-path">Admin &gt; Collections &gt; Menus</span>. From the list view, click the &#8220;Add&#8221; button. In the form that appears:</p>
<p><img class="diagram" src="http://blog.skybluecanvas.com/images/menu.form.jpg" alt="Menu Manager form image" width="464" height="184" /></p>
<p>provide the requested information.</p>
<div class="msg-info">
<h2>Note</h2>
<p>The Menu Type property has been deprecated so you do not need to complete this field.</p>
</div>
<div class="msg-info">
<h2>Tip</h2>
<p>You will need to know the numeric ID of the new menu so make note of it and hold onto it.</p>
</div>
<p>Then click Save.</p>
<p>No you can go back to <span class="admin-path">Admin &gt; Pages &gt; Edit</span> (your page) and on the Meta Data tab, select your new menu from the options list and save your page.</p>
<p>You have now successfully created a new menu and added a page (menu item) to the new menu.</p>
<h2>Displaying a Menu</h2>
<p>Displaying your menu involves two other concepts in SkyBlueCanvas: <a href="http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-v11-rc1-skins-explained/">templates</a> and <a href="http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/skybluecanvas-fragments-explained/">fragments</a>.</p>
<p>Templates and fragments make up the presentation or &#8220;view&#8221; portion of your web page. They are where you define the HTML structure of pages (templates) and collections or content types (fragments). They may be a little tricky to grasp at first, but once you understand them, they are very powerful and flexible.</p>
<p>Your SkyBlueCanvas installation, provided you are using v1.1 RC1 or later, should already have a Menu Fragment included. We are going to modify this fragment, or add to it rather, first.</p>
<p>Using your FTP client, navigate to <span class="file-path">/skyblue_root/data/skins/techjunie/fragments/menu/</span> and make a copy of <span class="file-name">view.php</span>. Name the new file <span class="file-name">mymenu.php</span>. Then open the file with the text editor of your choice.</p>
<div class="msg-info">
<h2>Tip</h2>
<p>If you have installed your own skin, you can simply copy <span class="file-path">/skyblue_root/data/skins/techjunkie/fragments/</span> to your new skin.</p>
</div>
<p>In the file <span class="file-name">mymenu.php</span> you will see the following code:</p>
<pre class="php">&lt;?php
  global $Router;
  global $Filter;
?&gt;
&lt;div class="horizontal-menu"&gt;
  &lt;?php if (count($data)) : ?&gt;
  &lt;ul&gt;
    &lt;?php foreach ($data as $item) : ?&gt;
    &lt;?php if (not_valid_menu($item)) continue; ?&gt;
    &lt;li&lt;?php the_class($item); ?&gt;&gt;
      &lt;a href="&lt;?php the_link($item); ?&gt;"&gt;
          &lt;?php the_text($item); ?&gt;&lt;/a&gt;
    &lt;/li&gt;
    &lt;?php endforeach; ?&gt;
  &lt;/ul&gt;
  &lt;?php endif; ?&gt;
&lt;/div&gt;</pre>
<p>That looks pretty simple, huh?</p>
<p>We are going to need to modify the code a little bit but I promise it will be painless- and I will give you the full code when we are finished.</p>
<p>SkyBlueCanvas will know that this is a menu fragment (more on this later) so the menu items (actually the pages) will already be available to your code in the <span class="variable">$data</span> variable. We will only need to manually retrieve our new menu.</p>
<p>Now you can refer back to the Menu ID I asked you to hold onto.</p>
<pre class="php">&lt;?php

  /*
  * Set this to the ID of the menu you created
  */

  $my_menu_id = 3;

  /*
  * Get the new menu from storage
  */

  $menu = $Core-&gt;SelectObj(
    $Core-&gt;xmlHandler-&gt;ParserMain(SB_XML_DIR . "menus.xml"),
    $my_menu_id
  );
?&gt;</pre>
<p>Now we have our menu items and our new menu. We can start building the menu HTML.</p>
<p>We will start with a basic HTML structure:</p>
<pre class="php">&lt;div class="mymenu"&gt;
  &lt;?php if ($menu-&gt;showtitle) : ?&gt;
  &lt;h2&gt;&lt;?php echo $menu-&gt;title; ?&gt;&lt;/h2&gt;
  &lt;?php endif; ?&gt;
  &lt;ul class="verticalmenu"&gt;

  &lt;/ul&gt;
&lt;/div&gt;</pre>
<p>That&#8217;s not too bad. We are almost finished building our menu HTML. Now all we need to do is loop through the <span class="variable">$data</span> list, and display each of the items in our menu. Here is how the looping is done:</p>
<pre class="php">  &lt;?php foreach ($data as $item) : &gt;

  &lt;?php endforeach; ?&gt;</pre>
<p>We only want to show links to pages that are published, so we will add a single line to make sure the menu item can be displayed:</p>
<pre class="php">  &lt;?php foreach ($data as $item) : &gt;
  &lt;?php if (not_valid_menu($item)) continue; ?&gt;

  &lt;?php endforeach; ?&gt;</pre>
<p>Now we want to filter the <span>$data</span> items to only show items in our new menu. We do this with a single line of code:</p>
<pre class="php">  &lt;?php foreach ($data as $item) : &gt;
  &lt;?php if (not_valid_menu($item)) continue; ?&gt;
  &lt;?php if ($item-&gt;menu != $menu-&gt;id) continue ; ?&gt;

  &lt;?php endforeach; ?&gt;</pre>
<p>Wow! That was pretty easy and we are moving right along &#8230;</p>
<p>The only thing we have left to do is display the menu item:</p>
<pre class="php">  &lt;?php foreach ($data as $item) : &gt;
  &lt;?php if (not_valid_menu($item)) continue; ?&gt;
  &lt;?php if (!$item-&gt;menu == $my_menu_id) continue ; ?&gt;
  &lt;li&lt;?php the_class($item); ?&gt;&gt;
    &lt;a href="&lt;?php the_link($item); ?&gt;"&gt;
        &lt;?php the_text($item); ?&gt;&lt;/a&gt;
  &lt;/li&gt;
  &lt;?php endforeach; ?&gt;</pre>
<p>And believe it or not, you have  just built a new menu, as well as your first SkyBlueCanvas Fragment. There is only one last step, and this one is the simplest of all.</p>
<p>Up to this point, we have created a new Menu object in the SkyBlueCanvas admin and written a new menu Fragment. The only thing that remains is to tell SkyBlueCanvas where to display the fragment. To do this, go to <span class="file-path">/skyblue_root/data/skins/techjunkie/</span> (or your skin) and open <span class="file-name">skin.text.html</span> in your text editor. You will see the following code:</p>
<pre class="html">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" {doc:lang}&gt;
  &lt;head&gt;
    &lt;title&gt;[[page.title]]&lt;/title&gt;
    &lt;meta http-equiv="Content-Type"
      content="text/html;charset=UTF-8" /&gt;
    &lt;?php echo $this-&gt;get_meta_data(); ?&gt;
    &lt;link rel="stylesheet"
    type="text/css"
    href="&lt;?php echo $this-&gt;get_path(); ?&gt;css/TechJunkie.css" /&gt;
    &lt;!--#plugin.preloader--&gt;
  &lt;/head&gt;
  &lt;body id="homepage"&gt;
    &lt;div id="wrap"&gt;
      &lt;!--#plugin:fragment(header)--&gt;
      &lt;div id="menu"&gt;
        &lt;!--#plugin:fragment(menu,view,menu=1)--&gt;
      &lt;/div&gt;
      &lt;div id="content-wrap"&gt;
        &lt;div id="main"&gt;
          &lt;!--#plugin:fragment(page,view)--&gt;
        &lt;/div&gt;
        &lt;div id="sidebar"&gt;
          &lt;!--#plugin:fragment(sidebar)--&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;div id="footer-wrap"&gt;
        &lt;!--#plugin:fragment(footer)--&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Notice the lines that look like this:</p>
<pre class="html">&lt;!--#plugin:fragment(page,view)--&gt;&gt;</pre>
<p>These tokens are the code that tell SkyBlueCanvas where to load a fragment, which fragment to load, and which view (PHP file) to load. So the only thing you need to do is add a token for your new menu in the location in the HTML where you want the menu to appear. Let&#8217;s assume you want your new menu to appear at the top of the sidebar. You will change the code to look like this:</p>
<pre class="html">
<div id="sidebar">
 &lt;!--#plugin:fragment(menu,mymenu)--&gt;</div>
</pre>
<p>Now test your new menu by pointing your browser to your web site. Your new menu should appear at the top of the sidebar.</p>
<div class="msg-info">
<h2>Note</h2>
<p>You will need to make this change for all of the skins HTML files, <span class="file-name">skin.contacts.html</span> and <span class="file-name">skin.standard.html</span>.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.skybluecanvas.com/skybluecanvas-lightweight-cms/creating-menus-skybluecanvas-v11/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
