Welcome Guest, Not a member yet? Register   Sign In
Organization brick wall
#1

[eluser]nZac[/eluser]
Ok I am working on getting my website's shifted over to CI based but I need clarification that I am doing this right.

I have a standard html flow. Header, Nav bar, Content, sidebar and footer. For every page I will need to load all of these views, but only content and sidebar really ever change. Do I have to do: $this->load->view('header') every time in the controller? Or is that the way to do it? Am I over thinking this?

Nick
#2

[eluser]tonanbarbarian[/eluser]
there are various templating libraries that you can use, most included in the forum or the wiki
they allow you to create an overall template and your views just return the content.
for things like header, navbar, sidebars and footers you use what are often referred to as elements
these are view files, often named differently, that contain small sections to be displayed

doing things this way allows for further abstraction of the design so that the template of the site is kept seperate from the content of individual pages
#3

[eluser]umefarooq[/eluser]
try to load only dynamic content in you template, if you header is static not changing for every page leave it in you template no need to call

Code:
$this->load->view(‘header’)

every time, i hope you content and menus and side bar are dynamic data is coming from database than you can use

Code:
$this->load->view(‘content’)
$this->load->view(‘navbar’)
$this->load->view(‘sidebar’)

and if you footer is also dynamic then you can carry on.
#4

[eluser]nZac[/eluser]
I will look more into the templateing library, and post any questions. Thanks for your help!




Theme © iAndrew 2016 - Forum software by © MyBB