public function edit($commentId) { //Checks if the user is admin if (!is_admin()) { show_404(current_url()); } //Set the validation rules $this->load->library('form_validation'); $validation_rules = array(array('field' => 'comment_user_name', 'label' => 'Nombre', 'rules' => 'required'), array('field' => 'comment_user_email', 'label' => 'Email', 'rules' => 'required'), array('field' => 'comment_content', 'label' => 'Comentario', 'rules' => 'required')); $this->form_validation->set_rules($validation_rules); //If the form has been submited it process the data and creates the comment if ($this->form_validation->run()) { /* ** Gets the comment data ** */ //Gets the comment id $commentData['comment_id'] = $commentId; //Gets the comment content $commentData['comment_content'] = $this->input->post('comment_content'); //Gets the user data $commentData['comment_user_name'] = $this->input->post('comment_user_name'); $commentData['comment_user_email'] = $this->input->post('comment_user_email'); $commentData['comment_user_url'] = $this->input->post('comment_user_url'); //Updates the comment $this->CommentModel->editComment($commentData); //Redirects to the comment header('location: ' . comment_url($commentId)); } else { $commentData = $this->CommentModel->getComment($commentId); $data['comment'] = $commentData['comment']; $data['title'] = 'Editar Comentario'; $this->load->view('templates/header', $data); $this->load->view('templates/admin/menu'); $this->load->view('comments/edit_comment', $data); $this->load->view('templates/footer'); } }
$i = 0; foreach ($answers as $answer) { if ($answer->comment_parent == $comment->comment_id) { ?> <article class="comment" > <h4><a href="<?php echo $answer->comment_user_url; ?> "><?php echo $answer->comment_user_name; ?> </a></h4> <small class="info"> <a href="<?php echo comment_url($answer->comment_id); ?> ">#<?php echo $answer->comment_id; ?> </a> <?php echo $answer->comment_date; ?> </small> <br> <p><?php echo $answer->comment_content; ?> </p> </article>