<?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/"
	>

<channel>
	<title>bharat sharma</title>
	<atom:link href="http://bharatsharma.blog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bharatsharma.blog.com</link>
	<description>It's Good to share knowledge</description>
	<pubDate>Thu, 02 Jul 2009 13:37:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Drupal Cache</title>
		<link>http://bharatsharma.blog.com/2009/07/02/drupal-cache/</link>
		<comments>http://bharatsharma.blog.com/2009/07/02/drupal-cache/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 13:25:30 +0000</pubDate>
		<dc:creator>bharatsharma83@gmail.com</dc:creator>
		
		<category><![CDATA[drupal]]></category>

		<category><![CDATA[cache]]></category>

		<category><![CDATA[cms]]></category>

		<guid isPermaLink="false">http://bharatsharma.blog.com/?p=20</guid>
		<description><![CDATA[
Caching is required to prevent dynamic websites numerous trips to the database to retrieve information about saved content, user, setting and config. Caching is used to speed up a website performance and visibility.
Drupal uses its cache API to provide caching of modules, node and pages. The default table in which drupal stores the module settings [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li>Caching is required to prevent dynamic websites numerous trips to the database to retrieve information about saved content, user, setting and config. Caching is used to speed up a website performance and visibility.</li>
<li>Drupal uses its cache API to provide caching of modules, node and pages. The default table in which drupal stores the module settings is called &#8216;cache&#8217;. We can create our own cache tables for various modules. The only requisite of cache API for custom cache tables is that the structure must be identical to the default cache table.</li>
<li>Besides cache table drupal also ships with three other cache tables know as</li>
</ul>
<p><em>cache_page</em> (stores cache of anonymous pages)</p>
<p><em> cache_menu</em> (stores cache for navigational menus)</p>
<p><em>cache_filter</em> ( stores cache copy of node&#8217;s content)</p>
<ul>
<li>The <em>drupal_page_cache_header()</em> prepares the cache data by setting HTTP headers.</li>
<li><strong>Functions of cache API<br />
</strong></li>
</ul>
<p><strong> Three important cache functions:</strong></p>
<p><strong> cache_set(</strong><em>$cid, $table=&#8217;cache&#8217;, $data</em>,<em> $expire</em>=CACHE_PERMANENT, $header=NULL)</p>
<p>where , $cid= Unique cache ID</p>
<p>$table= Name of the cache table to store the data, by default &#8216;cache&#8217; table is used.</p>
<p>$data= data to store in the cache.</p>
<p>$expire=The cache data expire time. You can use CACHE_PERMANENT, CACHE_TEMPORARY or a Unix Timestamp. By default CACHE_PERMANENT is set.</p>
<p>$headers= The HTTP header passed to the browser.</p>
<p><strong>cache_get(</strong><em>$cid</em><strong>, </strong><em>$table</em><strong>=</strong>&#8216;cache&#8217;<strong> )</strong></p>
<p><strong> </strong>where $cid= The cahe id of the data to retrieve.</p>
<p>$table= The table name from which data retrieved. The cache table is used by Default.</p>
<p><strong>cache_clear_all(</strong><strong></strong><em>$cid</em>=NULL<em>,$table=NULL,$wildcard=NULL)</em></p>
<p>where $cid=if set,  clear only the given cache ID, otherwise delete all expire entries.</p>
<p>$table=the table to delete from.if not set entries from cache_block and cache_page table will be deleted.</p>
<p>$wildcard=if set to TRUE , all cache entries with ID contains a substring similar to $cid wil be deleted.</p>
<p>8yjebzxq9v</p>
]]></content:encoded>
			<wfw:commentRss>http://bharatsharma.blog.com/2009/07/02/drupal-cache/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Drupal Forms API</title>
		<link>http://bharatsharma.blog.com/2009/06/29/drupal-forms-api/</link>
		<comments>http://bharatsharma.blog.com/2009/06/29/drupal-forms-api/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 13:34:52 +0000</pubDate>
		<dc:creator>bharatsharma83@gmail.com</dc:creator>
		
		<category><![CDATA[drupal]]></category>

		<category><![CDATA[cms]]></category>

		<category><![CDATA[form api]]></category>

		<guid isPermaLink="false">http://bharatsharma.blog.com/?p=14</guid>
		<description><![CDATA[This post is about the Form API of drupal6, You may find this post written in a little bit of unimpressive way, this is bcoz i am running short of time these days nonetheless i would like your suggestions and comments at any time and will try to make them happening:
Forms API

The forms API abstracts [...]]]></description>
			<content:encoded><![CDATA[<p>This post is about the<strong> Form API </strong>of drupal6, You may find this post written in a little bit of unimpressive way, this is bcoz i am running short of time these days nonetheless i would like your suggestions and comments at any time and will try to make them happening:</p>
<p><strong><em>Forms API</em></strong></p>
<ul>
<li>The forms API abstracts forms into a nested array of properties and values.</li>
<li><em>$form_values </em>is array which holds form elements values.</li>
<li>The form token (form unique id) is stored in the variables table as drupal_private_key.</li>
<li><em>drupal_get_form() </em>function interact with drupal form.</li>
<li><em>hook_elements() </em>function is used to define element type.</li>
<li>hook_element() can be used to define your own element types in your module.</li>
<li><em>element_info()</em> hook collects all the properties for all form elements.</li>
</ul>
<p><strong>FORM PROPERTIES</strong></p>
<ul>
<li><em>#validate</em> property is used to validate the form elements.</li>
<li><em>#base</em> is used to apply same validator to several forms.</li>
<li><em>#submit</em> handles form submission. If there is no property named <em>#submit</em>, drupal looks for function name &#8220;formID_submit()&#8221; or failing that drupal again search for &#8220;#basevalue_submit&#8221;.</li>
<li><em>#after_build</em> property will call all functions of a form.</li>
<li><em>#theme</em> is used to set a theme to an existing form.</li>
<li><em>#pre_render</em> property used to call the functions just before the transformation of form from a data structure to HTML.</li>
<li><em>#prepend, #suffix</em> properties are used to prepend and append text to  the form elements. drupal also uses these properties while rendering the form.</li>
<li><em>#method</em> property is used to set the form method to <em>post.</em> By default it is set to post, Also<em> get</em> method is not supported by the form API.</li>
<li><em>#tree</em> : Setting #tree to TRUE gives a nested array of fields with there values. While #tree is set to FALSE, we get a flattened representation of field name and values.</li>
</ul>
<p><strong>FLOW of form formation:</strong></p>
<p>when a module contains a form code is called by drupal the form datastructure renders form into html in the following sequence:</p>
<p>call drupal_get_form()<strong> -&gt; </strong>call hook_elements()['defining element types such as radio buttons, chekcboxes, textfiels']<strong> -&gt; </strong>call elements_info() [information about the related properties ,values and functions] <strong>-&gt; </strong>#validate property <strong>-&gt; </strong>#submit property</p>
<p>Bibliography: Apress Pro Drupal Devlopement (ycu73k6ath)</p>
]]></content:encoded>
			<wfw:commentRss>http://bharatsharma.blog.com/2009/06/29/drupal-forms-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Drupal Sessions</title>
		<link>http://bharatsharma.blog.com/2009/06/25/drupal-sessions/</link>
		<comments>http://bharatsharma.blog.com/2009/06/25/drupal-sessions/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 06:41:47 +0000</pubDate>
		<dc:creator>bharatsharma83@gmail.com</dc:creator>
		
		<category><![CDATA[drupal]]></category>

		<category><![CDATA[content management system]]></category>

		<category><![CDATA[open source]]></category>

		<category><![CDATA[sessions]]></category>

		<guid isPermaLink="false">http://bharatsharma.blog.com/?p=3</guid>
		<description><![CDATA[Bibliography: Apress Pro Drupal developement]]></description>
			<content:encoded><![CDATA[<p style="margin-bottom: 0cm">Drupal sessions:</p>
<p style="margin-bottom: 0cm">
<p style="margin-bottom: 0cm"><strong>How Sessions works on drupal:</strong></p>
<p style="margin-bottom: 0cm;font-weight: normal">The page request send by the browser includes a 32-character ID known as PHPSESSID  under set- cookie tag, which is used as the key to the session information that drupal stores about session.</p>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">The settings 	for session management are done in three files i.e. .htaccess, 	settings.php nad bootstarp.inc</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">By default 	drupal uses the cookie based session management instead of URL base 	session management. If the browser doesn&#8217;t accept cookies ,  a 	session cannot be established</p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">The PHP 			directive &#8217;sessions.use_only_cookies&#8217; is set to 1 in settings.php 			to accept cookie based sessions.</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">The PHP 			directive &#8217;sessions.use_trans_sid&#8217; is set to 0 in settings.php to 			reject URL  based sessions.</p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">At the 	installation time Drupal turns off the PHP&#8217;s &#8217;session.auto_start&#8217; 	functionality in .htaccess file to take full control over sessions.</p>
</li>
</ul>
<p style="margin-bottom: 0cm">
<p style="margin-bottom: 0cm"><strong>Why Drupal need sessions?</strong></p>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">To handle the 	viewing preferences of the site content according to viewer status.</p>
</li>
<li>
<p style="margin-bottom: 0cm"><strong>To remember the viewing 	preferences</strong><span style="font-weight: normal">: Drupal stores 	sessions in &#8217;sessions&#8217;  table, the session table is used to  	associate the sessions Ids with the user ids to retrieve the viewing 	preferences of a user. It applies a join query on session and user 	tables using session ids and user ids to know the user role. Session 	data of a user is viewable by $user-&gt;session of $user object.</span></p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">To 			represent a session for anonymous user, the &#8217;session&#8217; table &#8216;uid&#8217; 			column is set to 0.</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">To 			represent a session for login user, the  &#8217;session&#8217; table &#8216;uid&#8217; 			column is set to user Id with a new session Id such that the 			session does&#8217;nt get hijacked. If a user logs out, the row for that 			session is removed from the database immediately.</p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0cm"><strong>To remember the comments 	preferences: </strong><span style="font-weight: normal">In comment.module 	session is used to store viewing preferences for users, i.e. </span></p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm"><span style="font-weight: normal">$_SESSIONS['comment_mode']=$mode </span></p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">$_SESSIONS['comment_sort']=$order</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">$_SESSIONS['comment_comments_per_page']=$comments_per_page</p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">To handle 	file uploads</p>
</li>
</ul>
<p style="margin-bottom: 0cm;font-weight: normal">
<p style="margin-bottom: 0cm"><strong>Session Life time</strong></p>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">Sessions 	lifetime related settings are located in settings.php, By default</p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">ini_set(&#8217;session.cache_expire&#8217;, 			    200000);  // 138.9 days</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">ini_set(&#8217;session.cookie_lifetime&#8217;, 			 2000000); // 23.1 days</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">ini_set(&#8217;session.gc_maxlifetime&#8217;, 			  200000);  // 55 hours</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p style="margin-bottom: 0cm"><strong>Other Information</strong></p>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">Writing 	session in the session table is the last task of drupal while 	serving pages.</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">Drupal does 	not store session information , the first time a user visits a site. 	This is to reduce the load on the sessions table generated by 	crawlers.</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">Drupal $user 	object is first built during the DRUPAL_BOOTSTRAP_SESSION	 phase of 	bootstrapping by sess_read().</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">While 	deploying drupal on multiple subdomains, you can create a unique 	session name for each site by adding ini_set(&#8217;session.name&#8217;, 	&#8216;my-site-unique-name_PHPSESSID&#8217;); in settings.php</p>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">If you need 	to store short term data for anonymous users, use the $_SESSION 	superglobal e.g.</p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">$_SESSION['anonymous_data']=$anonymous_data;</p>
</li>
</ul>
</li>
</ul>
</li>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">If you want 	to store a permanent data to a user, save it in the $user object 	e.g.</p>
<ul>
<li>
<ul>
<li>
<p style="margin-bottom: 0cm;font-weight: normal">$user-&gt;login_name=$login_name; 			user_save();</p>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<p style="margin-bottom: 0cm;font-weight: normal">csmpqgbe7r</p>
<p><a href="http://technorati.com/faves?sub=addfavbtn&amp;add=http://bharatsharma.blog.com"><img src="http://static.technorati.com/pix/fave/tech-fav-1.png" alt="Add to Technorati Favorites" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://bharatsharma.blog.com/2009/06/25/drupal-sessions/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
