CodeIgniter Forums

Full Version: How to Organize JS and CSS files and blocks in CodeIgniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Unknown[/eluser]
Hello!

I have a problem on 'how to organize' my 'JS and CSS files and blocks'.
All of then are put in a 'header.php' file, but this file are loaded in some situations (every time!) that some 'JS and CSS files and blocks' couldn't exist.

The Context

I'm developing a simple CRUD system and my 'view' folder are like this:
Code:
(view)
-- (includes)
---- header.php // logo and navigation (shouldn't change) but I need to place different JS and CSS files and blocks
---- footer.php // copyright and credits (shouldn't change)
---- template_view.php
-- xxx_list.php    // block content that will be placed between header and footer
-- xxx_create.php  // (the same)
-- xxx_edit.php    // (the same)
-- ...

And this is my 'template_view.php' file:

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

Loaded from controller like this:

Code:
$data['main_content'] = 'xxx_edit';
$this->load->view('includes/template_view', $data['main_content']);

The Problem

(1) Considering this structure and that I have a specific (and different) 'JS block' and some 'JS files' that should be loaded for each view. How is the best way to do that? The same are applied to CSS case?
(2) An approach like .NET MasterPages is a good idea?

I hope that these questions should be useful for everyone!

Thanks,

Marcel