CodeIgniter Forums
Codeigniter Simple Template Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: External Resources (https://forum.codeigniter.com/forum-7.html)
+--- Forum: Addins (https://forum.codeigniter.com/forum-13.html)
+--- Thread: Codeigniter Simple Template Library (/thread-65180.html)



Codeigniter Simple Template Library - allenlee - 05-11-2016

Yesterday I coded a simple template library for my personal use, I think it may help someone else, so I post the Github link here.

https://github.com/terrylinooo/Codeigniter-Simple-Template-Library

If you ever used WordPress to build websites, you may know WordPress uses something like wp_head() , wp_footer() to manage the HTML output, this library does the same thing and it is more light-weight and simple.

[font=Consolas, 'Liberation Mono', Menlo, Courier, monospace]<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <title><?= CI_title() ?></title>
   <?= CI_head() ?>
</head>
[/font]

<body<?= CI_body_attr() ?>> 

some thing here

[font=Consolas, 'Liberation Mono', Menlo, Courier, monospace]<?= CI_footer() ?>
</body>
</html>
[/font]


Check out my Git to read full document about how to use it.


RE: Codeigniter Simple Template Library - natanfelles - 05-21-2016

Good job! Thanks.


RE: Codeigniter Simple Template Library - allenlee - 05-22-2016

I am glad you like it!  Heart

If the CSS or Javascript snippet are loaded by every pages, I usually put them in the style.css or script.js

It is useful for programmings like to hard-coding CSS and Javascript snippet in Controllers, just for styling single page or a few pages.

For example, I hard-coding those CSS only for login and register page in User Controller.

[Image: 4OTFgkD.png]

Output:

[Image: fsqvwmx.png]



If anyone don't like hard-coding, it can be loaded from View as a varible.


PHP Code:
// Load view into a variable for importing CSS
// /views/css/user_page_css.php
$css_text $this->load->view('css/user_page_css'''true);
$this->layout->add_css_rawtext($css_text); 

I think it is convenient to use.  Blush