PHPEveryday.com PHP and Web Development Tutorial
What are you looking for?


Table of Content
Learn CodeIgniter Framework Tutorial

Learn CodeIgniter Basic
CI Framework
CI Installation
CI MVC
CI Parameter
CI GET
CI Database Config
CI Database
CI Show All Data
CI Show a Data
CI GET Data

Learn CodeIgniter Form
CI Skeleton
CI Structure
CI Layout
CI Menu
CI Text
CI Centralizing
CI CSS
CI HTML
CI Form Code
CI HTML Style
CI Table
CI Insert Data
CI Table Library
CI Table List
CI URL Helper
CI Single Data
CI Form Parameters
CI Updating Data
CI Deleting Data

CodeIgniter - Form: Adding CSS


CodeIgniter Form Step By Step Tutorial - Part 7: At previous post, we talk about how to collect all parameters at one general method at model. Now, we see another advantage of that way. For example, we will add a css. Follow these steps:
  1. define general css that used. Open "config.php" within directory CodeIgniter\system\application\config.
  2. Add following code. The line posisi is up to you. I add at last line before ?>
    $config['css'] = 'mystyles.css';
    
  3. Create a file named mystyles.css within root application: \CodeIgniter\.
  4. Enter example code like this:
    h1{
    	font-family:Verdana, Arial, Helvetica, sans-serif;
    	font-size:30px;
    }
    p{
    	font-family:Georgia, "Times New Roman", Times, serif;
    	font-size:12px;
    }
    #menu{
    	height:50px;
    }
    #menu ul{
    	list-style-type:none;
    	margin-left:0px;
    }
    #menu li{
    	float:left;
    	padding:10px;
    }
    #footer{
    	font-family:Arial, Helvetica, sans-serif;
    	font-size:10px;
    }
    
  5. Open model file named "books_model.php" within CodeIgniter\system\application\models. Add two lines like line 12 and 13 following code:
    <?
    class books_model extends Model{
    	
      function books_model(){
    	parent::Model();
    	$this->load->helper('url');				
      }
    	
      function general(){
    	$this->load->library('MyMenu');
    	$menu = new MyMenu;
    	$data['base']		= $this->config->item('base_url');
    	$data['css']		= $this->config->item('css');		
    	$data['menu'] 		= $menu->show_menu();
    	$data['webtitle']	= 'Book Collection';
    	$data['websubtitle']= 'We collect all title of 
    		                   books on the world';
    	$data['webfooter']	= '© copyright by step 
    		                   by step php tutorial';
    		
    	return $data;	
      }
    }
    ?>
    
  6. Then, update "books_main.php" within CodeIgniter\system\application\views. Update <head></head>, like this:
    <html>
    <head>
    <link rel="stylesheet" type="text/css" 
          href="<?php echo "$base/$css"?>">
    </head>
    <body>
    <div id="header">
    <? $this->load->view('books_header'); ?>
    </div>
    <div id="menu">
    <? 	$this->load->view('books_menu'); ?>
    </div>
    
    test list
    
    <div id="footer">
    <? $this->load->view('books_footer'); ?>
    </div>
    
    </body>
    </html>
    
  7. Last, update "books_input.php" within CodeIgniter\system\application\views. Update <head></head>, like this:
    <html>
    <head>
    <link rel="stylesheet" type="text/css" 
          href="<?php echo "$base/$css"?>">
    </head>
    <body>
    <div id="header">
    <? $this->load->view('books_header'); ?>
    </div>
    <div id="menu">
    <? $this->load->view('books_menu'); ?>
    </div>
    
    test input
    
    <div id="footer">
    <? $this->load->view('books_footer'); ?>
    </div>
    
    </body>
    </html>
    
Point your browser to http://localhost/CodeIgniter/index.php/books/main. May be get like this: codeigniter form - use css


Series this article:
OOP Pattern - Registry: Monostate Registry Pattern
OOP Pattern - Registry: Embedded Registry
CodeIgniter - Form: Adding CSS


Tag: CodeIgniter, framework, MVC, CSS Category: PHP Framework Post : February 24th 2008 Read: 14,392 Bookmark and Share

blog comments powered by Disqus


Database Tutorial
  • Learn PHP MySQL
  • Learn PHP ADOdb
  • Learn PHP Data Object/PDO
  • Learn PHP XML
  • Learn PHP SimpleXML
Security Tutorial
  • Learn PHP Security
  • Learn HTTP Authentication
  • Learn PHPSecureSite
Framework Tutorial
  • Learn CodeIgniter
  • Learn Joomla
  • Learn Smarty
  • Learn Zend Framework
Template Tutorial
  • Learn Joomla Template
  • Learn WordPress Template
API Tutorial
  • Learn Facebook
JS Framework Tutorial
  • Learn MooTools
  • Learn JQuery
AJAX Tutorial
  • Learn AJAX in 10 Minutes
  • Learn AJAX Client Side
  • Learn AJAX PHP
  • Learn AJAX Remote Server
  • Learn AJAX Repetitive
  • Learn AJAX MySQL
  • Learn AJAX Grid
Web Services Tutorial
  • Learn Web Services NuSOAP
  • Learn Web Services WSDL
  • Learn Web Services WSDL Array
  • Learn Web Services .NET Grid
  • Learn Web Services WDDX
Package Post
  • Joomla Intro
  • Joomla Component
  • Joomla Module
  • Joomla MVC
  • Joomla MVC Backend
  • PostNuke Intro
  • Zend Framework Intro
  • Zend Framework Action
  • Zend Framework Database
  • Zend Framework Registry
  • Zend Framework Config
  • Zend Framework Login
  • Zend Framework Session
  • PHP Array Tips
  • PHP File Tips
  • PHP Email
  • PHP Ms Excel
  • PHP Pattern
  • PHP SMS
  • Flash Database
  • PHP Multitier
  • jQuery Introduction
  • jQuery Selectors
  • Portable Web Server
  • Web Mobile Intro
  • Drupal Installation
  • Drupal Configuration