title: How to display error or success message in a template file?
body: <p>I want to show message on some condition in a template file(custom module template file).I am having following code.</p>
  
  <pre><code>&lt;?php
   if(count($collection)): ?&gt;             
          &lt;?php foreach($collection as $coll): ?&gt;         
                     some calculations                   
          &lt;?php endforeach; ?&gt;
  &lt;?php else: ?&gt;
          &lt;?php $message = $this-&gt;__('There is no data available'); ?&gt;
          &lt;?php echo Mage::getSingleton('core/session')-&gt;addNotice($message);?&gt;
  &lt;?php endif;?&gt;
  </code></pre>
  
  <p>But this is not working properly. The message is displayed on other pages not on the same page.</p>