Current Version of Codefight CMS Available for Download:

            « Version 1.1.4 »

            NOTE: The code available is same as the code used for this site at the time of release.

            Codefight CMS is based on Codeigniter PHP Framework which is very easy to learn.

            It would be nice to hear back some feedback. Also you can contribute with code and helping translating language files in your language.

            You can use this CMS in anyway you want. You can modify as you like and use commercially for free.

 

Select Language.[TESTING For Next Release.]

English | नेपाली | French | German | Korean

Login | Select Language | Fri, 12 Mar 10 01:03:46 -0700

New Codefight Asset Manager a codeigniter library

2009-03-13 16:52:28Damodar Bashyal

 

Today i wrote new asset manager for my cms by taking ideas from contributions on codeigniter. This is very useful for my cms. I am going to modify more in the future as i have time. But for now i would like to show how it works.

STEP 1:

I have a config file called MY_config. And, i autoload this config on config/autoload.php

CODE:

1-
2-<?php
3-$autoload['config'] = array('MY_config');
4-?>
5-

Also, i autoload my new library in this file, along with other libraries as:

CODE:

1-
2-<?php
3-$autoload['libraries'] = array('database', 'session','login', 'assets');
4-?>
5-
STEP 2:

Now i need to edit MY_config.php file.

CODE:

1-
2-<?php
3-/*
4- * DEFFINE BELOW ITEMS FOR ASSETS MANAGEMENT
5- * dir is relative to base dir
6- * filenames should not have extensions i.e. no .css or .js
7- */

8-
9-//Base Path where index.php or admin.php is located
10-$config['cf']['base_path'] = dirname(FCPATH) . '/';
11-
12-/*
13- * assets directory relative to base_path above
14- * trailing slash (/) required if not empty e.g. 'assets/'
15- * if empty then just ''
16- */

17-$config['cf']['assets_dir'] = 'assets/';
18-
19-/*
20- * js (script) directory
21- * No trailing or leading slashes (/)
22- */

23-$config['cf']['js_dir'] = 'js';
24-
25-/*
26- * css directory
27- * No trailing or leading slashes (/)
28- */

29-$config['cf']['css_dir'] = 'css';
30-
31-//do js and css located in multifolder like admin, frontend, common
32-//default is false
33-$config['cf']['is_js_css_split'] = true;
34-
35-/*
36- * if is_js_css_split is true, define directories they can be found according to preferences in an array
37- * e.g. css can be found at: assets/common/css or, assets/admin/css etc...
38- * Script stops search when it finds one.
39- */

40-$config['cf']['js_css_dir'] = array(
41-'frontend',
42-'common',
43-'admin'
44- )
;
45-
46-/*
47- * Define css that need to be autoloaded in every page
48- */

49-$config['cf']['defaults']['css'] = array(
50-'all' => array('helper','header', 'menuLeft', 'jquery.jdMenu', 'footer')

51- );
52-
53-/*
54- * Define js that need to be autoloaded in every page
55- */

56-$config['cf']['defaults']['js'] = array('jquery', 'jquery.dimensions', 'jquery.positionBy', 'jquery.bgiframe', 'jquery.jdMenu');
57-?>
58-
STEP 3:

Now on controller, or view file load css and js as follow:

CODE:

1-
2-<?php
3-$assets = array();
4-
5-//load all required css
6-//if media type not defined, screen is default.
7-//$assets['css'] = array('admin','swiff','box','upload');
8-$assets['css'] = array('all' => array('page', 'special'));
9-
10-//load all required js
11-$assets['js'] = array('xyz','abc');
12-
13-$this->assets->load($assets);
14-?>
15-
STEP 4:

Now its time to echo loaded css and js. Put the below code wherever you want to echo it. definitely its between :

CODE:

1-
2-<?php
3-$this->assets->get();
4-?>
5-
It'll echo css|js as: If you view source of this page, you'll understand what i'm talking about.
CODE:

1-
2-<link rel=“ stylesheet“ href=“http://www.codefight.org/ assets/frontend/css/page.css“ type=“text/css“ media=“all“ />
3-...
4-<script type=“text/javascript“ src=“http://www.codefight.org/assets/frontend/js/jquery.js“></script>
5-...
6-
STEP 5:

This step should have been bit before but it really doesn't matter. Just upload the asset manager library to library folder.

Thats it!!!


Bookmark and Share

Test only 1st ever comment

13/03/09 06:33:30|Test Test

 

 





Javascript must be enabled to post comments!