<?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>&#60;title&#62; &#187; drupal</title>
	<atom:link href="http://www.adammoro.com/blog/tag/drupal/feed" rel="self" type="application/rss+xml" />
	<link>http://www.adammoro.com/blog</link>
	<description>Internet Marketing, Web Development and Programming Stuff</description>
	<lastBuildDate>Fri, 19 Nov 2010 19:58:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>uri_part: A PHP Function for Working with the Current URI</title>
		<link>http://www.adammoro.com/blog/uri-part-php-function-for-working-with-current-uri.html</link>
		<comments>http://www.adammoro.com/blog/uri-part-php-function-for-working-with-current-uri.html#comments</comments>
		<pubDate>Tue, 09 Mar 2010 14:55:24 +0000</pubDate>
		<dc:creator>Adam Moro</dc:creator>
				<category><![CDATA[Code Snippets & Examples]]></category>
		<category><![CDATA[Content Management]]></category>
		<category><![CDATA[drupal]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.adammoro.com/blog/?p=142</guid>
		<description><![CDATA[A PHP function that makes it extremely easy to display dynamic content within your existing Content Management System (CMS), web application framework or standard "PHP-enabled" website. function uri_part($n) { $path = explode("/", $_SERVER["REQUEST_URI"]); for ($i = 0; $i &#60;= count($path); $i++) { if(is_null($path[$i]) &#124;&#124; $path[$i] == "") { unset($path[$i]); } } $path = array_values($path); switch($n) ...]]></description>
			<content:encoded><![CDATA[<p>A PHP function that makes it extremely easy to display dynamic content within your existing Content Management System (CMS), web application framework or standard "PHP-enabled" website.</p>
<pre>function uri_part($n) {
	$path = explode("/", $_SERVER["REQUEST_URI"]);
	for ($i = 0; $i &lt;= count($path); $i++) {
		if(is_null($path[$i]) || $path[$i] == "") {
			unset($path[$i]);
		}
	}
	$path = array_values($path);
	switch($n) {
		case 0: return @$path[0]; break;
		case 1: return @$path[1]; break;
		case 2: return @$path[2]; break;
		case 3: return @$path[3]; break;
	}
}
</pre>
<h2>Usage Examples</h2>
<p>Below are examples of how this function can be used in a template file such as the header.php file from your WordPress install or the page.tpl.php file from your Drupal install.</p>
</p>
<h3>Example 1</h3>
<pre>if (uri_part(0)) {
	echo "Hello part 0";
}	
</pre>
<h3>Example 2</h3>
<pre>&lt;title&gt;&lt;?php
if (uri_part(0)) {
	echo "Homepage Title";
}
elseif (uri_part(1)) {
	echo uri_part(1);
}
?&gt;&lt;/title&gt;
</pre>
<h3>Example 3</h3>
<pre>if (uri_part(2) == "some-category") {
	echo '&lt;ul id="silo"&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Silo Link 1&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Silo Link 2&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Silo Link ...&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;/ul&gt;';
}
if (uri_part(2) == "some-other-category") {
	echo '&lt;ul id="silo"&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Other Silo Link 1&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Other Silo Link 2&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;li&gt;&lt;a href="#"&gt;Other Silo Link ...&lt;/a&gt;&lt;/li&gt;';
	echo '&lt;/ul&gt;';
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.adammoro.com/blog/uri-part-php-function-for-working-with-current-uri.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

