Welcome Guest, Not a member yet? Register   Sign In
Problems with files in view
#1

(This post was last modified: 08-08-2017, 06:33 AM by Marcolino92.)

Hi guys, I ask you a question to which I found a somewhat spartan solution and I do not like it.

Then, in my Post.php file in controller, I have this code:

PHP Code:
class Post extends CI_Controller {
 
   
    public 
function __construct() {
 
       parent::__construct();
 
       $this->load->model('post_model');
 
       $this->load->helper('url_helper');
 
   }
 
   
    public 
function index() {
 
       $data['title'] = 'Title Page';
 
       $data['post'] = $this->post_model->get_post();
 
       $this->load->view('templates/header'$data);
 
       $this->load->view('index'$data);
 
   

Perfect, so I in the view folder, I have a file called index.php which is exactly the index of my site.

My question is the following, I would like to create a page called "hot.php" where the same thing as index.php is displayed but it shows the results according to the views.

I can not do this, using the Post.php file in controller, and the Post_model.php file in Models.

Would an idea be this?

PHP Code:
class Post extends CI_Controller {
 
   
    public 
function __construct() {
 
       parent::__construct();
 
       $this->load->model('post_model');
 
       $this->load->helper('url_helper');
 
   }
 
   
    public 
function index() {
 
       $data['title'] = 'Title Page';
 
       $data['post'] = $this->post_model->get_post();
 
       $this->load->view('templates/header'$data);
 
       $this->load->view('index'$data);
 
   }

    public function 
hot() {
      
$data['title'] = 'Title Page';
      
$data['post'] = $this->post_model->get_hot_post();
      
$this->load->view('templates/header'$data);
      
$this->load->view('hot'$data);
 
   
Reply


Messages In This Thread
Problems with files in view - by Marcolino92 - 08-08-2017, 06:32 AM
RE: Problems with files in view - by InsiteFX - 08-08-2017, 12:19 PM
RE: Problems with files in view - by Marcolino92 - 08-08-2017, 10:45 PM
RE: Problems with files in view - by InsiteFX - 08-09-2017, 12:22 AM
RE: Problems with files in view - by Marcolino92 - 08-09-2017, 12:30 AM
RE: Problems with files in view - by Wouter60 - 08-09-2017, 03:51 AM
RE: Problems with files in view - by Marcolino92 - 08-09-2017, 06:31 AM
RE: Problems with files in view - by ciadvantage - 08-16-2017, 06:19 PM
RE: Problems with files in view - by Wouter60 - 08-09-2017, 11:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB