Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try construct your controller like so:</p> <pre><code>public function blog( $blog_name = '', $action = '' ){ $this-&gt;load-&gt;model("blog_model"); // What if there is no blog name in the url if ( empty( $blog_name ) ) { // Load the list of blogs $data["result"] = $this-&gt;blog_model-&gt;getBlogs(); $this-&gt;load-&gt;view("view_blog", $data); } else { // If the blog name in url exists and there is no action display the blog if ( !empty( $blog_name ) &amp;&amp; empty( $action ) ) { $blog_name = $this-&gt;getLastUrl(); $data["result"] = $this-&gt;blog_model-&gt;getBlogDetails( $blog_name ); $data["comment"] = $this-&gt;blog_model-&gt;getBlogComments( $blog_name ); $this-&gt;load-&gt;view("view_blog_details", $data); } // else If there is the action "reply" check if there is some post else if ( $action == 'reply' &amp;&amp; $this-&gt;input-&gt;post( 'Comment' ) ) { $this-&gt;load-&gt;library( 'form_validation' ); $this-&gt;form_validation-&gt;set_rules( 'name', 'Name', 'trim|required|min_length[4]|xss_clean' ); $this-&gt;form_validation-&gt;set_rules( 'message', 'Comment', 'trim|required|min_length[4]|xss_clean' ); $this-&gt;form_validation-&gt;set_rules( 'email', 'Email Address', 'trim|required|valid_email' ); if($this-&gt;form_validation-&gt;run() == FALSE) { redirect( site_url( $blog_name ) ); } else { $msg = 'Message sent.'; $this-&gt;blog_model-&gt;addBlogComment(); // Redirect to prevent F5 submitting duplicate data redirect( site_url( $blog_name ) ); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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