<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Smart site nav</title>
	<atom:link href="http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/</link>
	<description></description>
	<pubDate>Thu, 20 Nov 2008 22:57:38 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
		<item>
		<title>By: Jennifer</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6947</link>
		<dc:creator>Jennifer</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6947</guid>
		<description>Cool idea! Thanks Jade!
</description>
		<content:encoded><![CDATA[<p>Cool idea! Thanks Jade!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jade</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6946</link>
		<dc:creator>Jade</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6946</guid>
		<description>My way was slightly different. Here's my navigation file:

&#60;?php


# set the info for the navi stuff. first part of each sub-array is the plain link, second is the active link.

	$nav["about"] = array("&#60;p&#62;&#60;a href=&#92;"/about&#92;"&#62;about&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/about&#92;"&#62;about&#60;/a&#62;&#60;/p&#62;");

	$nav["links"] = array("&#60;p&#62;&#60;a href=&#92;"/links&#92;"&#62;links&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/links&#92;"&#62;links&#60;/a&#62;&#60;/p&#62;");

	$nav["weblog"] = array("&#60;p&#62;&#60;a href=&#92;"/weblog&#92;"&#62;weblog&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/weblog&#92;"&#62;weblog&#60;/a&#62;&#60;/p&#62;");

	$nav["journal"] = array("&#60;p&#62;&#60;a href=&#92;"/journal&#92;"&#62;journal&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/journal&#92;"&#62;journal&#60;/a&#62;&#60;/p&#62;");

	$nav["contact"] = array("&#60;p&#62;&#60;a href=&#92;"/contact&#92;"&#62;contact&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/contact&#92;"&#62;contact&#60;/a&#62;&#60;/p&#62;");

	$nav["webcam"] = array("&#60;p&#62;&#60;a href=&#92;"/webcam&#92;"&#62;webcams&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/webcam&#92;"&#62;webcams&#60;/a&#62;&#60;/p&#62;");

	$nav["phlog"] = array("&#60;p&#62;&#60;a href=&#92;"/otw&#92;"&#62;phlog&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/otw&#92;"&#62;phlog&#60;/a&#62;&#60;/p&#62;");

	$nav["features"] = array("&#60;p&#62;&#60;a href=&#92;"/features&#92;"&#62;features&#60;/a&#62;&#60;/p&#62;", "&#60;p class=&#92;"active&#92;"&#62;&#60;a href=&#92;"/features&#92;"&#62;features&#60;/a&#62;&#60;/p&#62;");

	$active = getenv(QUERY_STRING);

# for each $x in $nav check if $x is the same as the query string and if it is use $x[1] otherwise use $x[0]

foreach ($nav as $bit =&#62; $link) {
	if ($bit == $active) {
	print $link[1];
	print "&#92;n";
	} else {
	print $link[0];
	print "&#92;n";
	}

}

?&#62;

So with the comments in there you can pretty much understand what it does, even if you weren't familiar with PHP.

Then I include this in each of my pages like this:

&#60;?php
include('http://www.whisper-gallery.com/shared/menu.php?links');
?&#62;

or..

include('http://www.whisper-gallery.com/shared/menu.php?weblog');

Just have the bit after the question mark match the name of whatever element of $nav in the navigation script applies to the section of the site that you are wanting to mark as active.

You need to include the navigation script using the full URL because PHP does not provide any function for including local scripts with information being passed to them. And believe me, I looked ;) 

Initially I was worried about having to use the full URL to include the script rather than just a local path, but the friend who hosts me said it was ok and wouldn't really use much more in the way of server resources because a properly configured server should recognise that it's requesting a page from itself rather than over the internet and skip a few steps in the whole thing process of serving the file to itself. Or something. Sorry, I'm not so great with web servers just yet ;)</description>
		<content:encoded><![CDATA[<p>My way was slightly different. Here&#039;s my navigation file:</p>
<p>&lt;?php</p>
<p># set the info for the navi stuff. first part of each sub-array is the plain link, second is the active link.</p>
<p>	$nav["about"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/about&#92;&#034;&gt;about&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/about&#92;&#034;&gt;about&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["links"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/links&#92;&#034;&gt;links&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/links&#92;&#034;&gt;links&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["weblog"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/weblog&#92;&#034;&gt;weblog&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/weblog&#92;&#034;&gt;weblog&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["journal"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/journal&#92;&#034;&gt;journal&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/journal&#92;&#034;&gt;journal&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["contact"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/contact&#92;&#034;&gt;contact&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/contact&#92;&#034;&gt;contact&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["webcam"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/webcam&#92;&#034;&gt;webcams&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/webcam&#92;&#034;&gt;webcams&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["phlog"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/otw&#92;&#034;&gt;phlog&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/otw&#92;&#034;&gt;phlog&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$nav["features"] = array(&#034;&lt;p&gt;&lt;a href=&#92;&#034;/features&#92;&#034;&gt;features&lt;/a&gt;&lt;/p&gt;&#034;, &#034;&lt;p class=&#92;&#034;active&#92;&#034;&gt;&lt;a href=&#92;&#034;/features&#92;&#034;&gt;features&lt;/a&gt;&lt;/p&gt;&#034;);</p>
<p>	$active = getenv(QUERY_STRING);</p>
<p># for each $x in $nav check if $x is the same as the query string and if it is use $x[1] otherwise use $x[0]</p>
<p>foreach ($nav as $bit =&gt; $link) {<br />
	if ($bit == $active) {<br />
	print $link[1];<br />
	print &#034;&#92;n&#034;;<br />
	} else {<br />
	print $link[0];<br />
	print &#034;&#92;n&#034;;<br />
	}</p>
<p>}</p>
<p>?&gt;</p>
<p>So with the comments in there you can pretty much understand what it does, even if you weren&#039;t familiar with PHP.</p>
<p>Then I include this in each of my pages like this:</p>
<p>&lt;?php<br />
include(&#039;http://www.whisper-gallery.com/shared/menu.php?links&#039;);<br />
?&gt;</p>
<p>or..</p>
<p>include(&#039;http://www.whisper-gallery.com/shared/menu.php?weblog&#039;);</p>
<p>Just have the bit after the question mark match the name of whatever element of $nav in the navigation script applies to the section of the site that you are wanting to mark as active.</p>
<p>You need to include the navigation script using the full URL because PHP does not provide any function for including local scripts with information being passed to them. And believe me, I looked <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Initially I was worried about having to use the full URL to include the script rather than just a local path, but the friend who hosts me said it was ok and wouldn&#039;t really use much more in the way of server resources because a properly configured server should recognise that it&#039;s requesting a page from itself rather than over the internet and skip a few steps in the whole thing process of serving the file to itself. Or something. Sorry, I&#039;m not so great with web servers just yet <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lynda</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6944</link>
		<dc:creator>Lynda</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6944</guid>
		<description>Jennifer also posted something &lt;a href="http://www.scriptygoddess.com/archives/000890.php"&gt;similar&lt;/a&gt; on the site not too long ago that will work in either PHP or Javascript.

Always good to have more options!</description>
		<content:encoded><![CDATA[<p>Jennifer also posted something <a href="http://www.scriptygoddess.com/archives/000890.php">similar</a> on the site not too long ago that will work in either PHP or Javascript.</p>
<p>Always good to have more options!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kristine</title>
		<link>http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6945</link>
		<dc:creator>kristine</dc:creator>
		<pubDate>Tue, 30 Nov 1999 00:00:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2002/05/15/smart-site-nav/#comment-6945</guid>
		<description>Yeah, I thought it looked familiar to something over here, but I didn't go looking like I should have!  Thanks for posting the link :)

Still, like you said, its good to have options, and it was a well-written tutorial, so I wanted to share :)</description>
		<content:encoded><![CDATA[<p>Yeah, I thought it looked familiar to something over here, but I didn&#039;t go looking like I should have!  Thanks for posting the link <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Still, like you said, its good to have options, and it was a well-written tutorial, so I wanted to share <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.507 seconds -->
