├── assets ├── css │ └── styles.css └── js │ └── scripts.js ├── .gitattributes ├── application ├── views │ ├── templates │ │ ├── scripts.php │ │ └── head.php │ ├── html.php │ └── pages │ │ └── template │ │ ├── index.php │ │ └── sections │ │ └── modal.php └── controllers │ └── Template.php ├── .gitignore └── README.md /assets/css/styles.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /assets/js/scripts.js: -------------------------------------------------------------------------------- 1 | var hello = ' ____ _ ___ _ _ _____ _ _ \n' 2 | +' / ___|___ __| | ___|_ _|__ _ _ __ (_) |_ ___ _ __ |_ _|__ _ __ ___ _ __ | | __ _| |_ ___ \n' 3 | +'| | / _ \\ / _` |/ _ \\| |/ _` | \'_ \\| | __/ _ \\ \'__| | |/ _ \\ \'_ ` _ \\| \'_ \\| |/ _` | __/ _ \\\n' 4 | +'| |__| (_) | (_| | __/| | (_| | | | | | || __/ | | | __/ | | | | | |_) | | (_| | || __/\n' 5 | +' \\____\\___/ \\__,_|\\___|___\\__, |_| |_|_|\\__\\___|_| |_|\\___|_| |_| |_| .__/|_|\\__,_|\\__\\___|\n' 6 | +' |___/ |_| \n' 7 | +'by @natanfelles' 8 | ; 9 | console.log(hello); 10 | -------------------------------------------------------------------------------- /application/views/templates/scripts.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | defined('BASEPATH') OR exit('No direct script access allowed'); 9 | /** 10 | * @var array $link_js 11 | * @var array $inline_js 12 | */ 13 | 14 | if (isset($link_js)): 15 | ?> 16 | 17 | 20 | 21 | 27 | 28 | 35 | 38 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /application/views/html.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | defined('BASEPATH') OR exit('No direct script access allowed'); 9 | /** 10 | * @var string $lang 11 | * @var string $body_attr 12 | * @var string $page 13 | * 14 | * @var CI_Controller $this 15 | */ 16 | ?> 17 | 18 | 19 | load->view('templates/head'); 21 | ?> 22 | > 23 | load->view("pages/{$filepath}"); 35 | $this->load->view('templates/scripts'); 36 | ?> 37 | 38 | 39 | -------------------------------------------------------------------------------- /application/views/pages/template/index.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | defined('BASEPATH') OR exit('No direct script access allowed'); 9 | /** 10 | * @var CI_Controller $this 11 | */ 12 | ?> 13 |
14 |
15 |

CodeIgniter Template

16 |

This is a simple example page.

17 |

18 | 21 |

22 |
23 |
24 | Created by 25 | Natan Felles 26 |
27 |
28 | load->view('pages/template/sections/modal'); 30 | -------------------------------------------------------------------------------- /application/views/templates/head.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | */ 9 | defined('BASEPATH') OR exit('No direct script access allowed'); 10 | /** 11 | * @var string $title 12 | * @var array $link_css 13 | * @var array $inline_css 14 | */ 15 | ?> 16 | 17 | 18 | 19 | 20 | <?= isset($title) ? $title : 'CodeIgniter' ?> 21 | 24 | 25 | 28 | 29 | 35 | 36 | 43 | 46 | 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CodeIgniter Template 2 | 3 | A Simple Template System to CodeIgniter 4 | 5 | ## Controllers usage 6 | 7 | * Language 8 | ```php 9 | $data['lang'] = 'pt-BR'; 10 | ``` 11 | 12 | * Page located in application/views/pages/template/index.php 13 | ```php 14 | $data['page'] = 'template/index'; 15 | ``` 16 | 17 | * Page Title 18 | ```php 19 | $data['title'] = 'CodeIgniter Template'; 20 | ``` 21 | 22 | * Body Attributes 23 | ```php 24 | $data['body_attr'] = 'class="grey"'; 25 | ``` 26 | * CSS links 27 | ```php 28 | $data['link_css'] = array( 29 | 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', 30 | base_url('assets/css/styles.css'), 31 | ); 32 | ``` 33 | 34 | * CSS inline. Used just in the current page 35 | ```php 36 | $data['inline_css'] = array( 37 | 'body {padding-top: 70px}', 38 | 'a {color: #dd4814}', 39 | ); 40 | ``` 41 | 42 | * JS links 43 | ```php 44 | $data['link_js'] = array( 45 | 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', 46 | 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', 47 | base_url('assets/js/scripts.js'), 48 | ); 49 | ``` 50 | 51 | * JS inline. 52 | ```php 53 | $data['inline_js'] = array( 54 | '$("#learn-more").modal({keyboard: false, show: false})', 55 | ); 56 | ``` 57 | 58 | * Loads the main view and set dynamic data 59 | ```php 60 | $this->load->view('html', $data); 61 | ``` 62 | -------------------------------------------------------------------------------- /application/controllers/Template.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | defined('BASEPATH') OR exit('No direct script access allowed'); 9 | 10 | /** 11 | * Class Template 12 | * 13 | * An example page using CodeIgniter Template 14 | */ 15 | class Template extends CI_Controller { 16 | 17 | 18 | /** 19 | * Template constructor 20 | */ 21 | public function __construct() 22 | { 23 | parent::__construct(); 24 | $this->load->helpers(['url']); 25 | } 26 | 27 | 28 | /** 29 | * Template index 30 | */ 31 | public function index() 32 | { 33 | // Language 34 | $data['lang'] = 'pt-BR'; 35 | 36 | // Page located in application/views/pages/template/index.php 37 | $data['page'] = 'template'; 38 | 39 | // Page Title 40 | $data['title'] = 'CodeIgniter Template'; 41 | 42 | // Body Attributes 43 | $data['body_attr'] = 'class="grey"'; 44 | 45 | // CSS links 46 | $data['link_css'] = array( 47 | 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css', // External 48 | base_url('assets/css/styles.css'), // Internal 49 | ); 50 | 51 | // CSS inline. Used just in the current page 52 | $data['inline_css'] = array( 53 | 'body {padding-top: 70px}', 54 | '.grey {background-color: #f9f9f9}', 55 | '.jumbotron {background-color: #343131; color: #b3b3b3 }', 56 | 'h1 {color: #fff !important}', 57 | '.glyphicon-fire {color: #dd4814; font-size: 150%}', 58 | '.btn-primary {background-color: #f9f9f9; color: #dd4814; border: 0}', 59 | '.btn-primary:hover {background-color: #dd4814; color: #fff}', 60 | '.btn-primary:focus {background-color: #dd4814 !important; color: #fff}', 61 | '.btn-primary:active {background-color: #4e4a4a !important; color: #fff}', 62 | 'a {color: #dd4814 !important}', 63 | ); 64 | 65 | // JS links 66 | $data['link_js'] = array( 67 | 'https://code.jquery.com/jquery-2.2.4.min.js', // External 68 | 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js', // External 69 | base_url('assets/js/scripts.js'), // Internal 70 | ); 71 | 72 | // JS inline. Uses jQuery! See application/views/templates/scripts.php 73 | $data['inline_js'] = array( 74 | '$("#learn-more").modal({keyboard: false, show: false})', 75 | ); 76 | 77 | // Loads the main view and set dynamic data 78 | $this->load->view('html', $data); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /application/views/pages/template/sections/modal.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | defined('BASEPATH') OR exit('No direct script access allowed'); 9 | ?> 10 | 11 | 47 | --------------------------------------------------------------------------------