Jump to content

CSS Not Working in Codeigniter


I-AM-OBODO

Recommended Posts

Can you show us an example.

 

my folder structure: application, css, images, js, system (index.php)

on my view i have a file service.php and i attached a style <link href="../../css/styles.css" rel="stylesheet" type="text/css">

on my editor, i could see the effects of my styles but when i view in browser, no effects

thanks

Link to comment
Share on other sites

What I do with CI is set up an autoloading model (config/autoload.php) with all my constants, so things like the site's name, full url paths for images, css, ans JS, and so on.

 

Example:

class Constants extends CI_Model {

public $CI;

/**
 * Constructor
 *
 */
function __construct()
{
	// Call the Model constructor
	parent::__construct();

	// Create an instance to CI
	$CI =& get_instance();

	// Load the settings, users & session models
	$CI->load->model('Settings_model', 'settings');
	$CI->load->model('Users_model', 'users');
	$CI->load->model('Session_model', 'user');

	// Define frequently used settings
	define('SITE_NAME', $this->get_setting('site_name'));
	define('ADMIN', 'admin/');
	define('ADMIN_URL', base_url() . 'app_path/views/' . ADMIN);
	define('FILES', '/var/www/path/to/app_path/files');  //full path to folder OUTSIDE of CMS application directory
	define('IMAGES', base_url() . 'app_path/views/images/');
	define('UPLOAD', 'app_path/views/images/');
	define('CSS', 'app_path/css/');

}

 

Then when you're using your frequent functions, you can do:

//  quick link to CSS
<?php echo link_tag(CSS . 'style.css'); ?>

// quick link for admin shtuff
<?php echo anchor(ADMIN . 'home', 'Admin Panel'); ?>

// regular linkage
<?php echo anchor('reviews/unread', 'Unread Reviews'); ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.