Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>1) I suggest you to load the url helper and do a redirect to <code>/news/</code> then. If you wish to display a confirmation of deletion, I suggest you to use <code>flash_message</code> from the <code>session</code> library, it permits to stock an alert in a session until you display it, it's specifically for that purpose.</p> <p>2) The only better thing you could possibly do might be making an homemade helper to manage your views, so you would only have to call a function with paramaters to output the view. But there is no other way to optimize it or save some lines of code.</p> <p>3) You did great, it's clean. :)</p> <p><strong>EDIT:</strong></p> <p>If you need to display a error or success message, please refer to flash_message of the <a href="http://codeigniter.com/user_guide/libraries/sessions.html" rel="nofollow">session library</a> of CodeIgniter, but here is an example.</p> <p>Set the error message in your controller, juste before redirecting to the index:</p> <pre><code>$this-&gt;load-&gt;library('session'); $this-&gt;session-&gt;set_flashdata('error_message', "This is my error message"); </code></pre> <p>And in your index view, you display it if it exists:</p> <pre><code>&lt;?if($this-&gt;session-&gt;flashdata('error_message')):?&gt; &lt;div class="nNote nFailure"&gt;&lt;p&gt;&lt;?=$this-&gt;session-&gt;flashdata('error_message');?&gt;&lt;/p&gt;&lt;/div&gt; &lt;?endif;?&gt; </code></pre> <p>Please note that a flash_message is shown once. Which means your index will show your error and then destroy the session message. This is the purpose of flash_message, to correctly and simply show error messages.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload