![]() |
How to create templates - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: How to create templates (/showthread.php?tid=73374) |
How to create templates - mitsol - 04-17-2019 Hi I am new to codeigniter and i want to create a template for my codeigniter website so that that template appears in in pages in both admin and front side of the website. I read tutorial for simple header and footer view files but that is not enough, i want full examples. If there are any prepared template demo available online then tell me here. Thanks in avance. RE: How to create templates - php_rocs - 04-17-2019 @mitsol, Maybe this will be useful to you... https://www.google.com/search?q=codeigniter+bootstrap+template+demo&rlz=1C1GCEB_enUS843US843&oq=codeigniter+bootstrap+template+demo&aqs=chrome..69i57.15285j0j7&sourceid=chrome&ie=UTF-8 RE: How to create templates - website - 04-18-2019 See blog Avenir:https://avenir.ro/en/ or buy book "Practical CodeIgniter 3"- Lonnie Ezell. RE: How to create templates - happyape - 04-18-2019 Which version of CodeIgniter are you using? If it's the latest CI4 - templating is very easy. Take a look at this - https://codeigniter4.github.io/userguide/outgoing/view_layouts.html Step 1 - create your template file - Views/app.php PHP Code: <!doctype html> Step 2 - create any page e.g. home page Views/homepage.php PHP Code: <?= $this->extend('app') ?> //This is the name of layout file above without ".php" Step 3 - In your controller PHP Code: public function index() Depending upon your are requirements - you can create different types of layouts e.g. publicLayout.php or adminLayout.php You can also include partials too - check out all options here - https://codeigniter4.github.io/userguide/outgoing RE: How to create templates - soap - 04-19-2019 Maybe you'll like BladeOne: https://github.com/EFTEC/BladeOne RE: How to create templates - HelenM - 04-19-2019 The best way is to load views within your views. Within views/content.php: <? $this->view('header', array('title'=>'The page title', 'keywords'=>'some keywords', 'etc'=>'...')); ?> <div id="content">My content here</div> <? $this->view('footer'); ?> So in your controller you would do this: $this->load->view('content', $data); $data could contain 'title' or 'keywords' and that would be implemented as such in your controller: $data['title'] = 'title'; $data['keywords' = 'keywords'; And this in your 'content' view: <? $this->view('header', array('title'=>$title, 'keywords'=>$keywords)); ?> <div id="content">My content here</div> <? $this->view('footer'); ?> This question is worded differently, but nearly identical to this one in substance: CodeIgniter or PHP Equivalent of Rails Partials and Templates RE: How to create templates - vincent78 - 04-20-2019 I've created a Layout Library that manages the templates. You can find it here: https://github.com/vmoulin78/codeigniter-layout-library |