<?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>SmartnetzoneDrupal &#187; Smartnetzone</title>
	<atom:link href="http://demo.smartnetzone.com/category/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://demo.smartnetzone.com</link>
	<description></description>
	<lastBuildDate>Mon, 15 Aug 2011 16:12:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Drupal url function</title>
		<link>http://demo.smartnetzone.com/drupal-url-function/</link>
		<comments>http://demo.smartnetzone.com/drupal-url-function/#comments</comments>
		<pubDate>Mon, 15 Aug 2011 16:12:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Drupal]]></category>

		<guid isPermaLink="false">http://demo.smartnetzone.com/?p=893</guid>
		<description><![CDATA[Hi everyone, in this post we will learn about drupal url function, which is very useful to create drupal internal and external paths. While developing modules we will need it very often. There are several ways to get the path using url function.

1. Simple Path:
In simple path we just pass the path in the url function.

Ex: $simple_path = url('admin/modules');
Output: /admin/modules

Here ...]]></description>
			<content:encoded><![CDATA[<p>Hi everyone, in this post we will learn about drupal url function, which is very useful to create drupal internal and external paths. While developing modules we will need it very often. There are several ways to get the path using url function.</p>
<p><a href="http://demo.smartnetzone.com/wp-content/uploads/2011/08/url.jpeg"><img class="aligncenter size-full wp-image-894" title="url" src="http://demo.smartnetzone.com/wp-content/uploads/2011/08/url.jpeg" alt="" width="140" height="160" /></a></p>
<h2>1. Simple Path:</h2>
<p>In simple path we just pass the path in the url function.</p>
<pre class="php">
Ex<span class="phpOperator">:</span> $simple_path <span class="phpOperator">=</span> url<span class="phpOperator">(</span><span class="phpString">'admin/modules'</span><span class="phpOperator">)</span><span class="phpText">;</span>
Output<span class="phpOperator">:</span> /admin/modules
</pre>
<p>Here we just pass the relative path. and we get the relative path in simple_path variable</p>
<h2>2. External Path:</h2>
<p>In external path we pass the external path in the url function.</p>
<pre class="php">
Ex<span class="phpOperator">:</span> $external_path <span class="phpOperator">=</span> url<span class="phpOperator">(</span><span class="phpString">'http<span class="phpOperator">:</span><span class="phpComment">//demo.smartnetzone.com'</span><span class="phpOperator">)</span><span class="phpText">;</span>
</span>Output<span class="phpOperator">:</span> http<span class="phpOperator">:</span><span class="phpComment">//demo.smartnetzone.com
</span></pre>
<p>Here we pass external path and get the external path in external_path variable</p>
<h2>3. Absolute Path:</h2>
<p>we can also get the absolute path using url function</p>
<pre class="php">
Ex<span class="phpOperator">:</span> $absolute_path <span class="phpOperator">=</span> url<span class="phpOperator">(</span><span class="phpString">'admin/modules'</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">'absolute'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> TRUE<span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
Output<span class="phpOperator">:</span> http<span class="phpOperator">:</span><span class="phpComment">//localhost/drupal_learning/admin/modules
</span></pre>
<p>Here &#8220;http://localhost/drupal_learning&#8221; is the path where the drupal is installed and including that it adds the path we pass via url function. and finally we get the absolute path as the output.</p>
<h2>4. Fragment:</h2>
<p>Its very useful for one page website. lets say for example, if we want to see the footer of the page, we have to scroll down to footer area. instead of that we call the footer id using fragment method.</p>
<pre class="php">
Ex<span class="phpOperator">:</span> $fragment <span class="phpOperator">=</span> url<span class="phpOperator">(</span><span class="phpString">'aboutus'</span>, <span class="phpFunction">array</span><span class="phpOperator">(</span><span class="phpString">'fragment'</span> <span class="phpOperator"><span class="phpOperator">=</span><span class="phpOperator">&gt;</span></span> <span class="phpString">'footer'</span><span class="phpOperator">)</span><span class="phpOperator">)</span><span class="phpText">;</span>
Output<span class="phpOperator">:</span> /aboutus#footer
</pre>
<p>Here with the path we pass an array in url function which has footer as the fragment. and when we go to the output link it will go to the footer area of aboutus page.</p>
]]></content:encoded>
			<wfw:commentRss>http://demo.smartnetzone.com/drupal-url-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
