Hi,
I don’t know if I can post this question here, but I’m new to CI and I have a question about the “master template” that you put here:
4. Add these line to your view file: <?php echo set_breadcrumb(); ?>. I suggest that you put it on master template so that it can save time as you don’t need to add text in every view page.
Is there any link with an example that shows how to use an master template? The best way to create this type of templates? I couldn’t find anything on google about it.
Another question: I can’t test this right now (i’m at work), but on function set_breadcrumb(), the second parameter (an array) is to exclude from the breadcrumb, right? Or the only way to exlude items is changing the config file?
Thanks and congratulations for the helper!
Sorry my bad english…
Let me explain as clearly as I can. Codeigniter basicaly consist of a controller with a view or some views. Here the example from CI 2.0.3 user guide, a controller that using single view file (controllers/blog.php):
<?php
class Blog extends CI_Controller {
function index()
{
$this->load->view('blogview');
}
}
?>
To using autocrumb, you can put <?php echo set_breadcrumb(); ?> on header, body or wherever you want, here’s the example of views/blogview.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My ERP</title>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/blueprint/screen.css" type="text/css" media="screen, projection">
</head>
<body>
<div class="breadcrumb">
<?php echo set_breadcrumb(); ?>
</div>
<div class="container">
This is content
</div>
<div class"footer">
This is footer
</div>
</body>
</html>
If using that way then you should put <?php echo set_breadcrumb(); ?> on every page view. With multiple views you can avoid that situation by creating header.php, footer.php, or maybe sidebar.php, menu.php along with blogview.php. Now, you controller will be like this:
<?php
class Blog extends CI_Controller {
function index()
{
$this->load->view('header');
$this->load->view('blogview');
$this->load->view('footer');
}
}
?>
Strip header and footer content from views/blogview.php:
<div class="container">
This is content
</div>
The views/footer.php:
<div class"footer">
This is footer
</div>
</body>
</html>
For header, consider that header is always loaded and same for every page view then you can take benefit to put <?php echo set_breadcrumb(); ?> on header. See below example, views/header.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My ERP</title>
<link rel="stylesheet" href="<?php echo base_url();?>assets/css/blueprint/screen.css" type="text/css" media="screen, projection">
</head>
<body>
<div class="breadcrumb">
<?php echo set_breadcrumb(); ?>
</div>
That’s what I called as master template. So, we just need to put <?php echo set_breadcrumb(); ?> on views/header.php instead of that on every page view. Do you get it ?
For the second question, yes you can exclude from set_breadcrumb parameter. The helper will search exclude variable from set_breadcrumb’s parameter first. If the parameter is empty then it will search value from config[‘exclude’] on config/breadcrumb.php