[eluser]charlie spider[/eluser]
First off, when i say header and footer here i am talking about the design elements of the page, not the actual html components. So a header is the area at the top of the visible page with the company logo, login info, navigation, etc. and the footer is the info bar at the bottom of the page with site navigation text links, copyright info, link to our business, etc.
Anyways, i find that most sites my wife and i build will have the exact same footer for every page and only a handful of different headers. So i'll take all of the pages with the same header and footer and use one view as an overall page template. So typically i end up with a view called "home_view", then a general content page called "inner_view" then other pages like "all_products_view" and "product_details_view". Then i load my content into those dynamically through different modules:
Code:
$this->data['content'] = $this->load->view('modules/product_shirts_details', $this->data, TRUE);
or
$this->data['content'] = $this->load->view('modules/product_footwear_details', $this->data, TRUE);
which loads into:
Code:
$this->load->view(product_details_view, $this->data);
As for the actual html header information that you were referring to, i use a basic CMS that i built to store the page name, page title, url, nav level, path, meta keywords, meta description, etc, etc, etc in the database. All of this info gets dumped into an array called $page that's loaded into the view through $data.
i should also point out that i typically only use one controller for the frontend of my sites which starts by looking at the incoming url:
Code:
$url = $this->Site_model->get_pageID($this->uri->segment(1));
and then loads all applicable content based on that. The beauty of this is that if we do a site redesign and restructure the site map, i can grab all of the incoming links to old pages and redirect them to the new content in it's new location.
All of my navigation is built dynamically and also loaded as a module, like:
Code:
$this->data['menu'] = $this->load->view('modules/site_menu', $this->data, TRUE);
$this->data['site_info'] = $this->load->view('modules/site_info', $this->data, TRUE);
As for highlighting the current page, you just use an if statement when generating the navigation to compare each page name against the value you passed in the $page array and then change the css class for that link:
Code:
echo '<ul class="topNav">';
foreach ($nav as $link)
{
if ( $link['pageTitle'] == $page['pageTitle'] )
{
echo '<li class="'.$page['pageTitle'].'">';
}
else
{
echo '<li>';
}
echo '<a href="'.base_url() . $link['pageURL'].' title=">'.strtoupper( $link['pageName'] ).'</a></li>';
}
echo '</ul>';
So ultimately my "product_details_view" page might look kinda like:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META NAME="keywords" CONTENT="<?=$page['pageKeywords'];?>">
<META NAME="description" CONTENT="<?=$page['pageDesc'];?>">
<title><?=$page['pageTitle'];?> - <?=$website;?></title>
<?=$style;?>
<?=$javascript;?>
<?=$menu_scripts;?>
</head>
<body>
<div id="wrapper">
<?=$search_header;?>
<h2 class="hdr"><?=$website;?></h2>
<h1 class="hdr"><?=ucwords($page['pageName']);?></h1>
<?=$menu;?>
<?=$content;?>
<?=$side_bar;?>
</div>
<?=$site_info;?>
</body>
</html>
All pretty simple stuff, no rocket science, but still pretty flexible. It also saves me a lot of time as i get to reuse a ton of code from project to project, even if i always do end up tweaking and modifying and refining and tweaking it so more every time.
i know this goes a little beyond what you were talking about but i just wanted to suggest an alternative to what i feel is the pretty limited, typical
load header,
load body,
load footer
hope this helps