CodeIgniter Forums
CI-Theme - Theme Library (Updated) - Printable Version

+- CodeIgniter Forums (
+-- Forum: External Resources (
+--- Forum: Addins (
+--- Thread: CI-Theme - Theme Library (Updated) (/thread-69383.html)

CI-Theme - Theme Library (Updated) - bkader - 11-13-2017

Greetings everyone,


I have made a lot of changes to the library, it is not publicly available for the moment but I think I will share it with you :Smile
Now, the theme library is completely independent of the application, all assets, views, partials and layouts are manageable and served from whithin the the themes functions.php file using the same mechanism that WordPress use, I mean filters and actions.

To enqueue stylesheet for instance, all you have to do is add and action in your functions.php like so:
PHP Code:
add_action('enqueue_styles', function(){

Now, the bootstrap.min.css file will be added as <link> tag on your output.
There are plenty of other filters and actions and I might add more. Here is a brief list of available ones at the moment:
PHP Code:
    This action can be used to enqueue all your stylesheets,
    JavaScripts, meta tags and all other stuff in case you don't
    want to use separate actions and filters for each element.
add_action('after_theme_setupe', ...);

    Because the library serves files from within the theme's folder,
    you can change that behavior by defining where your views, 
    layouts and partials are located.

    A .htaccess file will be created on each folder to prevent direct
    access to them;

// To play with <html>, <body> and language attributes and charsets
add_filter('html_class', ...);
add_filter('body_class', ...);
add_filter('language_attributes', ...)
add_filter('the_charset', ...);

// To alter page's title and content
add_filter('the_title', ...);
add_filter('the_content', ...);

// Meta tags, StyleSheets and JavaScripts have all filters and actions like the one below
// Simply change 'metadata' and 'styles' or 'scripts' instead
add_filter('before_metadata', ... );
add_action('enqueue_metadata', ... );
add_filter('after_metadata', ... );

// To add specific partials
add_action('enqueue_partials', ... );

    You can use provided checkers like: is_module(), is_controller() and
    is_method() to check on which area your are.
    If used with no arguments, they make sure you are on a module, controller
    and method (the last two are obvious).

    You can add condition by adding arguments like so:
    is_module('name'), is_module('one, two, three'), is_module('one', 'two', 'three')
    or is_module(['one', 'two', 'three']). (same for controller and method)

// Using checkers above, you can set which layout to use and which view
// to load using 'theme_layout' and 'theme_view' filter:
add_filter('theme_layout', function($layout) {
   if (is_controller('welcome'))
       return 'welcome'// layout named: 'welcome' will be used.

The library has a default header, footer and layouts templates. So even if you don't have those files you will still get the full html.
These can be overridden by creating header.php and footer.php in your theme's folder.
I am still working on the library and enhancing it. Let me know if you're interested Wink 


After many modifications and commits, I finally got to version 1.0.0 of my CodeIgniter Theme Library. Here is what's about (read more on github).

CodeIgniter Theme Library

There are plenty of CodeIgniter template library. I tried most of them and I must say that they rock. Though, I had to make my own that suits my needs and that may be easy to implement, easy to understand and easy to use.

What is this library about?

It offers you the possibility to implement theming feature to your CodeIgniter applications with simple folders structure and ease of use (It works even when using HMVC).


Feel free to try it and contribute and have a nice day.