Welcome Guest, Not a member yet? Register   Sign In
make template for view page
#1

[eluser]himalking[/eluser]
hi guys
I want to make a template view to load all my views through it (something like this)

<?php $this->load->view('inclues/header'); ?>
<?php $this->load->view($main_content); ?>
<?php $this->load->view('inclues/footer'); ?>


my question is:
1- is this template structure is ok?
2- is there a problem if I declare the <html> and <body> tags in both header and footer?
"is it a problem to declare them multiple times?"

thanx in advance
#2

[eluser]techgnome[/eluser]
1) It's similar to the structure I use.
2) No and yes. No in that a second head or body tag shouldn't hurt the rendering. Yes in that there's no reason for it and will result in a non-conforming non-validated rendering of your page and could cause placement side effects.


Here's the full extent of the template I use:
Code:
&lt;?php if ($content_view == '') {$content_view = 'site/mainpage';} ?&gt;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;?php $this->load->view('template/header');?&gt;
&lt;body&gt;
    <div id="container">
&lt;?php
    $this->load->view('template/album_blocks');
?&gt;&lt;!-- begin main page --&gt;
&lt;?php if($show_right_col) {$this->load->view('template/content_narrow'); } else {$this->load->view('template/content_wide');}?&gt;
&lt;!-- end main page --&gt;
&lt;?php $this->load->view('template/footer'); ?&gt;
    </div>
&lt;/body&gt;
&lt;/html&gt;
My template opens the html tags and the body tags, and is responsible for closing them too. Then I simply load other views to fill in the areas between. It even takes care of loading default content in case there was an error and the content wasn't specified. My header view loads the head tag. and so on.

-tg
#3

[eluser]russ_kern[/eluser]
My template structure is basicly the same as yours...

I only call my &lt;html&gt;&lt;head>&lt;/head&gt;&lt;body> in the header and my &lt;/body&gt;&lt;/html> in the footer.

I agree with techgnome except that when I was very early on in web work I found that calling things like css, head tags, etc multiple times could give unreliable results across browsers (I always learned these things the hard way Smile )

R
#4

[eluser]himalking[/eluser]
Thank you guys, now the image is clear




Theme © iAndrew 2016 - Forum software by © MyBB