CodeIgniter Forums
Skinning my CI App / Templating, styling questions - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Skinning my CI App / Templating, styling questions (/showthread.php?tid=7512)

Pages: 1 2


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]CARP[/eluser]
Hi guys
This is my first question related to CI, and I'd like to know which would be the best way to stylize my App.
Is there anything I should see? Any recommendations for this? I've gone through the user guide but this topic isn't covered (or I didn't found)

I mean: how to structure css, my views, controllers, etc. and how to build the skeleton (look) of my CI app

Thanks a lot in advance for your suggestions


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]Seppo[/eluser]
There are a couple of recommendations...
First, avoid URL rewriting for the static content folder. Take a look here in the "Removing the index.php file" section on how to create a rule to avoid apache rewrite (in the example, they escape images, but you can add styles, javascript, etc using pipes).

Other useful advice is to use the html helper functions for including images and links tags.

And for last, if you wanna use a common view in multiple controllers you have two choises:
- you can load multiples views inside your controller (take a look here, in "Loading multiple views")
- you can load a view inside another view, and the second view will have the same variables you have set for the first one.


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]CARP[/eluser]
Thanks Seppo
Is there any recommendation you can give me to start the skeleton?
I mean, should I do something like
- separate header, left col, body, footer, etc. in separate things?
- make all the skeleton in 1 view?
- ...etc?

Thanks again


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]Seppo[/eluser]
Well.. that depends on the layout you wanna use... I usually have a "standard" view and I pass a var with the name of the particular view I need for that controller.
Inside the "standard" view I load the other views I use like header, footer, etc and I am able to reuse some of those views when I need to do a template that does not use all of them


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]CARP[/eluser]
Cool tip!
Thanks Seppo


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]Tom Glover[/eluser]
I usually use a template then load the other view into a var in the controller and then call that var in the main template view. This means I can keep the layout the same.


Skinning my CI App / Templating, styling questions - El Forum - 04-12-2008

[eluser]CARP[/eluser]
[quote author="WackyWebs.net" date="1208044796"]I usually use a template then load the other view into a var in the controller and then call that var in the main template view. This means I can keep the layout the same.[/quote]

Sorry 4 my ignorance, but do you have a little sample code I can start from (to understand that) ?
Thanks


Skinning my CI App / Templating, styling questions - El Forum - 04-13-2008

[eluser]Unknown[/eluser]
I think you can use bamboo invoice project for the beginning. It's an open source CI project.
It's very good start point for CI new one. I've learned a lot from it.


Skinning my CI App / Templating, styling questions - El Forum - 04-13-2008

[eluser]Tom Glover[/eluser]
Yes here is a simple controller with the two views loaded:

Code:
function index()//simple controller
{
   $data[view] = $this->load->view('view1','',true)
   $this->load->view('view',$data)
}

View 1 - you do not always need to put html and body tags in a view that is called.
Code:
<html>
  <body>
    text or content here, do what you like.
  </body>
</html>

View 2
Code:
<html>
  <body>
    <?= $view ?>
  </body>
</html>



Skinning my CI App / Templating, styling questions - El Forum - 04-15-2008

[eluser]CARP[/eluser]
Hi TJ.
Sorry for answering too late, but I don't have too much time for playing with CI
By loading more than 1 view and assigning them to the $data or $template_data array var, makes CI to show errors regarding it doesn't recognize the variable names I have in my views. This sounds logic, so I think you have misspelled something in your code...

My idea was to do:
To make a common header, a common menu (left col.) and a common footer in my app, that's why I followed TJ's advice, but didn't work. Now

[quote author="Seppo" date="1208043564"]Inside the "standard" view I load the other views I use like header, footer, etc and I am able to reuse some of those views when I need to do a template that does not use all of them[/quote]

I didn't know I could call or load other views from a particular view. What if those views also have data I get from controller ?

Thanks a lot for helping