New to CI--Templating common data like external style sheet - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: New to CI--Templating common data like external style sheet (/showthread.php?tid=43859) |
New to CI--Templating common data like external style sheet - El Forum - 07-25-2011 [eluser]cwscribner[/eluser] Hi all. I'm a few minutes into CI and my question (which may be irrelevant) is how can I template things with CI? So instead of putting <link rel....> on every view, how can I make it more automated? New to CI--Templating common data like external style sheet - El Forum - 07-25-2011 [eluser]Mirge[/eluser] You could create header & footer views. views/header.php: Code: <html> views/footer.php: Code: </body> Naturally you'd create a folder "assets" in your application/ folder, and within that folder create your "css" folder, and put style.css there. You can use whatever folder you wanted, but it's common practice to use an assets/ folder. And then in your individual view files: Code: <?php $this->load->view('header'); ?> Hope that helps. New to CI--Templating common data like external style sheet - El Forum - 07-25-2011 [eluser]cwscribner[/eluser] So I'm having some trouble with links in my code apparently? I'll post in blocks to make it work. So here's what I've got... header view Code: <!DOCTYPE html> nav view Code: a bunch of links that the forums won't let me post for some reason... footer view Code: </body> welcome_message.php view Code: <?php welcome.php controller Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Right now, this doesn't display anything on the page. I followed your suggestion and created an assets directory that holds the css directory. I almost think that I may have overkilled it by using a controller on a page that doesn't need one but as I mentioned in my first post...I'm not very far into this. Any help would be greatly appreciated! :-) New to CI--Templating common data like external style sheet - El Forum - 07-25-2011 [eluser]cwscribner[/eluser] Ok, I figured out what the problem was...it was the header view. I changed the <?=siteurl();?> to an absolute path and it fixed the problem. I also removed everything from welcome_message.php and modified welcome.php to include the welcome_message.php. New to CI--Templating common data like external style sheet - El Forum - 07-25-2011 [eluser]Mirge[/eluser] Uhhhh....... A view doesn't load a controller... a controller loads the view. Before you dive too far in & get confused, take a bit to check out the user guide: http://ellislab.com/codeigniter/user-guide/toc.html Specifically: Application Flow Chart Model-View-Controller Then I'd make sure to read ALL items under "General Topics", especially controllers, views, and models. New to CI--Templating common data like external style sheet - El Forum - 07-27-2011 [eluser]joakley77[/eluser] Check out Carabiner. It allows you to group your assets (js/css) as well as minimizes them. http://codeigniter.com/wiki/Carabiner/ |