Welcome Guest, Not a member yet? Register   Sign In
Better view files
#12

Hmm, yeah I certainly don't want to echo out html using php Wink but thanks...

I started a simple test with the html parser.

PHP Code:
class Template_test extends CI_Controller {

    public function 
index()
    {
        
$this->db->select('*');
        
$this->db->from('pages');
        
$query $this->db->get();
        
        
$this->load->library('parser');

        
$url1 site_url('admin/template_test');

        
$data = array(
                
'url1'         => $url1,
                
'page_title'   => 'My Page Title',
                
'page_heading' => 'My Page Heading',
                
'pages' => $query->result_array()
        );

        
$this->load->view('admin/header');
        
$this->load->view('admin/body');
        
$this->parser->parse('admin/template/template-test'$data);
        
$this->load->view('admin/footer');
    }



And more view files looks a lot better:

Code:
<div class="pmf-container" >
    <div class="row pad" >
        <div class="col-sm-12">
            <header class="panel-heading font-bold">{page_title}</header>
            <section class="panel">
                <div class="panel-body">
                    {pages}
                        {name}
                    {/pages}

                </div>
            </section>
        </div>
    </div>
</div>

Like we discussed before I don't think there should be a great deal of logic in your views other than for loops and some simple if else statements. I like the idea of passing these vars to the view in a multi-dimensional array. Even removing the site_url() from the view and setting this as a one word variable and passing it to the view seems better. I'm also going to get rid of all the codeigniter form_helpers in the view, well most of them.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply


Messages In This Thread
Better view files - by ignitedcms - 07-31-2015, 03:46 PM
RE: Better view files - by John_Betong - 08-01-2015, 12:20 AM
RE: Better view files - by ignitedcms - 08-02-2015, 03:28 AM
RE: Better view files - by John_Betong - 08-02-2015, 05:58 AM
RE: Better view files - by Diederik - 08-02-2015, 04:15 AM
RE: Better view files - by ignitedcms - 08-02-2015, 04:54 AM
RE: Better view files - by ignitedcms - 08-02-2015, 06:36 AM
RE: Better view files - by John_Betong - 08-02-2015, 08:18 AM
RE: Better view files - by mwhitney - 08-04-2015, 07:19 AM
RE: Better view files - by ignitedcms - 08-04-2015, 08:32 AM
RE: Better view files - by John_Betong - 08-04-2015, 09:22 AM
RE: Better view files - by ignitedcms - 08-04-2015, 10:36 AM



Theme © iAndrew 2016 - Forum software by © MyBB