<?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>SoliTech GmbH &#187; navigation</title>
	<atom:link href="http://www.solitechgmbh.com/tag/navigation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.solitechgmbh.com</link>
	<description>Connecting businesses to people through effective online marketing strategy</description>
	<lastBuildDate>Thu, 13 May 2010 19:14:39 +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>Menu highlighting with CakePHP 1.2</title>
		<link>http://www.solitechgmbh.com/2008/06/06/menu-highlighting-with-cakephp-12/</link>
		<comments>http://www.solitechgmbh.com/2008/06/06/menu-highlighting-with-cakephp-12/#comments</comments>
		<pubDate>Sat, 07 Jun 2008 03:45:15 +0000</pubDate>
		<dc:creator>Gyuri</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[navigation]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.gyuropia.com/?p=41</guid>
		<description><![CDATA[As far as I can tell CakePHP 1.2 does not have a good navigation menu helper at the moment. That is probably because they have a good link builder that is very flexible so you can just throw some css togeather and make ome very decent looking menus. You can make them look good but ...<br /><a href="http://www.solitechgmbh.com/2008/06/06/menu-highlighting-with-cakephp-12/">Read more...</a>]]></description>
			<content:encoded><![CDATA[<p>As far as I can tell CakePHP 1.2 does not have a good navigation menu helper at the moment. That is probably because they have a good link builder that is very flexible so you can just throw some css togeather and make ome very decent looking menus. You can make them look good but wouldn&#8217;t it be nice to have a highlight effect that shows the current menu option you selected.</p>
<p>I found a pretty decent solution. It will figure out which section of the website you are in and highlight the proper link. It is pretty crude but it works for what I want it to do.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> MenuHelper <span style="color: #000000; font-weight: bold;">extends</span> Helper <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$helpers</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Html'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Highlight a menu option based on path
 *
 * A menu path gets passed and it compares to requestd path and sets the call to be highlighted.
 * Use regular ereg expressions in the pattern matching.
 *
 * @param path for wich the nav item should be highlighted
 * @param optional normal class to be returned, default navLink
 * @param optional highlight class to be returnd, default navLinkSelected
 * @return returns the proper class based on the url
 */</span>
	<span style="color: #000000; font-weight: bold;">function</span> highlight<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$normal</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'navLink'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$selected</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'navLinkSelected'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$normal</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$currentPath</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">here</span><span style="color: #339933;">,</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Html</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">base</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// if there is a star in the path we need to do different checking</span>
		<span style="color: #000088;">$regs</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">ereg</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span><span style="color: #000088;">$currentPath</span><span style="color: #339933;">,</span><span style="color: #000088;">$regs</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$class</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$selected</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$class</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>A usage example would be something like the following&#8230;<br />
Create something like this for each menu item. The string in highlight should be the path part you want the menu item highlighted for.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">link</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Home'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Home'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$menu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">highlight</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">link</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'My Account'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'/users'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'title'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'My Account'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'class'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$menu</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">highlight</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/users*'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>You also need to add some CSS for the menus. This is just an example. This code is used at <a href="http://www.rewardchamp.com">RewardChamp</a> if you want to take a look.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#navMenu</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">750px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">35px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navMenu</span> a<span style="color: #6666ff;">.navLink</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">font</span><span style="color: #00AA00;">:</span><span style="color: #993333;">normal</span> <span style="color: #933;">12px</span> Helvetica<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span> <span style="color: #933;">12px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navMenu</span> a<span style="color: #6666ff;">.navLink</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#3F3F3F</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#FFF</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navMenu</span> a<span style="color: #6666ff;">.navLinkSelected</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#B61D1D</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navMenu</span> a<span style="color: #6666ff;">.navLinkSelected</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#B61D1D</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.solitechgmbh.com/2008/06/06/menu-highlighting-with-cakephp-12/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
