CodeIgniter Forums
Template Lib/Parser question - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Template Lib/Parser question (/showthread.php?tid=53888)



Template Lib/Parser question - El Forum - 08-13-2012

[eluser]the_unforgiven[/eluser]
Using Phil Sturgeons library for templating i have
Code:
$this->template
     ->set_layout('default')
     ->build('admin/clientlist', $data);
in my controller, so oif i wanted to say if clientlist template is used do this how would i acheive this?

like
Code:
$template['clientlist']



Template Lib/Parser question - El Forum - 08-13-2012

[eluser]the_unforgiven[/eluser]
Anyone?

This will be what i should write in my view file to say if the template is a specific page/template then do this else do this.


Template Lib/Parser question - El Forum - 08-13-2012

[eluser]Aken[/eluser]
After a quick glance through the source, I don't see anything that passes the view name to the template content. You'd have to add that, either to your $data array, or modify the Template library to do it automatically.


Template Lib/Parser question - El Forum - 08-14-2012

[eluser]the_unforgiven[/eluser]
My full controller
Code:
$total = $this->client_model->client_count();
  $per_pg = 20;
  $offset = $this->uri->segment(3);

  $config['base_url'] = $data['base'].'/admin/clientlist/';
  $config['total_rows'] = $total;
  $config['per_page'] = $per_pg;
  $config['full_tag_open'] = '<div id="pagination">';
  $config['full_tag_close'] = '</div>';
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();
        $data['total_rows'] = $config['total_rows'];
  $data['show_from'] = $offset + 1;
  $data['show_to'] = $offset + $per_pg;
  if($data['show_to'] > $total) {
   $data['show_to'] = $total;
  }
        $data['query'] = $this->client_model->get_all($per_pg,$offset);
  
  $this->template
   ->enable_parser(TRUE)
   ->title(lang('client_title'));

  $this->template
   ->set_layout('default')
   ->build('admin/clientlist', $data);

So now i need to know how to get in my view file, if the template is set to clientlist for example so this, else show this...


Template Lib/Parser question - El Forum - 08-16-2012

[eluser]Phil Sturgeon[/eluser]
Code:
$this->template
     ->set_layout('default')
     ->set('is_client_list', true)
     ->build('admin/clientlist', $data);

TADAAAA! Smile


Template Lib/Parser question - El Forum - 08-16-2012

[eluser]the_unforgiven[/eluser]
Gracias great one!

Thanks Phil


Template Lib/Parser question - El Forum - 08-16-2012

[eluser]the_unforgiven[/eluser]
So would just do in view right:

?php if ($template['is_client_list'] == TRUE) { ?&gt;

blah blah