Created
March 2, 2012 20:29
-
-
Save jehoshua02/1961066 to your computer and use it in GitHub Desktop.
Playing around with nested views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Product extends CI_Controller { | |
public function index() | |
{ | |
// TODO Product->index() | |
} | |
public function add() | |
{ | |
// render form | |
$form_data = array( | |
'action' => base_url('product/add'), | |
'product' => $this->input->post('product') | |
); | |
$form = $this->load->view('product/add', $form_data, TRUE); | |
// then the layout | |
$layout_data = array( | |
'header' => NULL, | |
'content' => $form, | |
'footer' => NULL | |
); | |
$layout = $this->load->view('layout/default.php', $layout_data, TRUE); | |
// then the page | |
$page_data = array( | |
'meta' => NULL, | |
'title' => 'Add Product', | |
'css' => NULL, | |
'javascript' => NULL, | |
'content' => $layout | |
); | |
$page = $this->load->view('page/html5', $page_data); | |
} | |
} | |
/* End of file product.php */ | |
/* Location: ./application/controllers/product.php */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- meta --> | |
<meta charset="utf-8" /> | |
<!-- title --> | |
<title>Add Product</title> | |
<!-- css --> | |
<!-- javascript --> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="product_add"> | |
<h2>Add Product</h2> | |
<form action="http://localhost/portal/product/add" method="post"> | |
<label>SKU <input type="text" name="product[sku]" value="" /></label> | |
<label>Name <input type="text" name="product[name]" value="" /></label> | |
<input type="submit" name="product[submit]" value="Save" /> | |
</form> | |
</div> | |
</div><!-- end container --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment