<?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>Kurinchi Blogger Scribbles ... &#187; Session SetFlash</title>
	<atom:link href="http://kurinchilamp.kurinchilion.com/tag/session-setflash/feed" rel="self" type="application/rss+xml" />
	<link>http://kurinchilamp.kurinchilion.com</link>
	<description>On Open Source Technologies</description>
	<lastBuildDate>Fri, 03 Sep 2010 03:26:10 +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>cakePHP: Session enabled messages using Session-&gt;setFlash</title>
		<link>http://kurinchilamp.kurinchilion.com/2009/06/cakephp-session-enabled-messages-using-session-setflash.html</link>
		<comments>http://kurinchilamp.kurinchilion.com/2009/06/cakephp-session-enabled-messages-using-session-setflash.html#comments</comments>
		<pubDate>Wed, 10 Jun 2009 03:28:37 +0000</pubDate>
		<dc:creator>kurinchilamp</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[UI, CSS]]></category>
		<category><![CDATA[cakePHP]]></category>
		<category><![CDATA[layouts]]></category>
		<category><![CDATA[Session messages]]></category>
		<category><![CDATA[Session SetFlash]]></category>

		<guid isPermaLink="false">http://kurinchilamp.kurinchilion.com/?p=410</guid>
		<description><![CDATA[There are different ways to flash or publish the messages for a user action. Usability plays a major role in determining how the navigation pattern for a web application takes place. publishing the outcome of user action on the same page designing a single page to flash all success, error, warning, notice level messages designing [...]]]></description>
			<content:encoded><![CDATA[<p>There are different ways to flash or publish the messages for a user action. Usability plays a major role in determining how the navigation pattern for a web application takes place.</p>
<ul>
<li>publishing the outcome of user action on the same page</li>
<li>designing a single page to flash all success, error, warning, notice level messages</li>
<li>designing a separate page for each message that gets published for the user</li>
</ul>
<p><span id="more-410"></span><br />
<strong>In CakePHP, to publish a message on the same page you need to make the following settings in the controller and view</strong></p>
<p><em>In the controller</em><br />
//app/controllers/posts_controller.php<br />
&lt;?php<br />
function add(){<br />
if ($this->Post->save($this->data)) {<br />
      $this->Session->setFlash(&#8216;Your post has been saved.&#8217;);<br />
      $this->redirect(&#8216;/posts&#8217;);<br />
   }<br />
}<br />
?&gt;</p>
<p><em>In the view</em></p>
<p>//app/views/posts/add.ctp<br />
&lt;?php<br />
   if ($session->check(&#8216;Message.flash&#8217;)){<br />
		 $session->flash();<br />
   }<br />
   echo $content_for_layout;<br />
?&gt;</p>
<p><strong>To design a single page to flash all success, error, warning, notice level messages follow the steps below</strong></p>
<p><em>In the controller</em><br />
//app/controllers/posts_controller.php<br />
&lt;?php<br />
function add(){<br />
if ($this->Post->save($this->data)) {<br />
      $this->Session->setFlash(&#8216;Your post has been saved.&#8217;, &#8216;general&#8217;);<br />
      $this->redirect(&#8216;/posts&#8217;);<br />
   }<br />
} //end of add<br />
?&gt;</p>
<p><em>In the view</em></p>
<p>//app/views/layouts/general.ctp<br />
&lt;?php<br />
   echo &#8220;Message :: &#8220;.$content_for_layout;<br />
?&gt;</p>
<p>To design a separate page for each message, it is the same as the above step.But instead of one template file, you will have separate file layout file in /app/views/layout like error.ctp, warning.ctp, notice.ctp and custom design these pages to show the respective messages.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fkurinchilamp.kurinchilion.com%2F2009%2F06%2Fcakephp-session-enabled-messages-using-session-setflash.html&amp;linkname=cakePHP%3A%20Session%20enabled%20messages%20using%20Session-%3EsetFlash"><img src="http://kurinchilamp.kurinchilion.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Save/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://kurinchilamp.kurinchilion.com/2009/06/cakephp-session-enabled-messages-using-session-setflash.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
