New to CI--Templating common data like external style sheet |
[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?
[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.
[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! :-)
[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.
[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.
[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/ |
Welcome Guest, Not a member yet? Register Sign In |