Welcome Guest, Not a member yet? Register   Sign In
layout question
#1

[eluser]cerberus478[/eluser]
Hi

I want to create a layout for my website, but it doesn't seem to be working. I tried to do it like the tutorial said but I get this error

An Error Was Encountered

Unable to load the requested file: cms/layout.php

How would I be able to link my pages to the layout page

Thanks
#2

[eluser]ojcarga[/eluser]
What tutorial are you talking about? also, post the code you are using dude.
#3

[eluser]cerberus478[/eluser]
I'm using the codeigniters user_guide tutorial.
I managed to make a layout for the first page but any pages after that it doesn't work.
I don't get an error, the layout just doesn't work.

My layout.php is
Code:
<html>
<head>
<link rel="stylesheet" type="text/css" href="cms/layout.css" media="screen" />
</head>
<body>
<?php echo anchor('bras/bras', 'Bras');?>
<?php echo anchor('lingerie/lingerie', 'Lingerie'); ?>
<?php echo anchor('corsets/corsets', 'Corsets'); ?>
</body>
</html>

my bras controller is
Code:
<?php

class Bras extends CI_Controller{

public function __construct()
{
  parent::__construct();
  $this->load->model('bras_model');
  $this->load->helper('url');
  $this->load->helper('form');
}

function index() {

  $data['title'] = "Voluptuous Decadents";
  $data['heading'] = "Bras";
  $data['query'] = $this->db->get('bras');
  
  $this->load->view('layout');  
  $this->load->view('bras/bras', $data);
  
}

function bras_view(){
  
  $data['title'] = "Voluptuous Decadents";
  $data['heading'] = "Bras";
  $this->db->where('slug', $this->uri->segment(3));
  $data['query'] = $this->db->get('bras');
  
  $this->load->view('layout');  
  $this->load->view('bras/bras_view', $data);
  
}

}
?>
#4

[eluser]ojcarga[/eluser]
Look, don't really understand why, but, what you are trying to do is to load 2 views on the same controller method, that is ok, it is not bad, but why are you doing that?

Are you sure "bras/bras.php" and "bras/bras_view.php" both exist?

It means you should have this structure of files/folders

application
-views
--bras
---bras.php
---bras_view.php

and to access the controller you posted above you should go to:

your_site_base_url/bras ---> for accessing the index() method
your_site_base_url/bras/bras_view ---> for accessing the bras_view() method.

Let me know if we are on the same point, if not, maybe what you need is to review what MVC is. The CI user guide is very useful for having an global understanding of how CI works, so please, read it step by step trying to understand every little piece of code there and come back if you don't understand something Smile




Theme © iAndrew 2016 - Forum software by © MyBB