Welcome Guest, Not a member yet? Register   Sign In
Template Library Version 1.4
#61

[eluser]newsun[/eluser]
And since it looked like you were a bit unsure on setting up the config file...

To set the default template group

Code:
$template['active_template'] = 'default';

Then you need the whole set settings for each group you create, 'default' is the group listed

Code:
$template['default']['template'] = 'master_template';
$template['default']['regions'] = ''
$template['default']['parser'] = 'parser';
$template['default']['parser_method'] = 'parse';
$template['default']['parse_template'] = FALSE;

Simply add another section to define other groups and specify the data for them:

Code:
$template['another_group']['template'] = 'another_template';
$template['another_group']['regions'] = ''
$template['another_group']['parser'] = 'parser';
$template['another_group']['parser_method'] = 'parse';
$template['another_group']['parse_template'] = FALSE;

Then do as mentioned above.
#62

[eluser]M4rc0[/eluser]
Great, i was having that question as well!

Man, i love this template lib :cheese:
#63

[eluser]macigniter[/eluser]
First of all, I love this library. Although I was just pulling my hair with the following problem.

I wanted to write a parsed view to my template with the following line:

$data = array("somedata" => "some data");
$this->template->write_view("content", "home/hello", $data);

So far, so good. But I couldn't figure out why my view file wouldn't be parsed until I found out that {somedata} would not be parsed in my view file. Instead I had to use: <?= $somedata ?>

I am used to write my templates like {this}. Is there a way to change the config file in order to parse this style of placeholders?

Thanks!
#64

[eluser]opel[/eluser]
I think it is $this->template->parse_view{“content”, “home/hello”, $data)}

if you look at post on previous page about setting up your template config too.

Hope that helps
#65

[eluser]macigniter[/eluser]
Arghh... clearly I should have caught that... Thanks!!
#66

[eluser]opel[/eluser]
Has anyone been able to get this to work with a module library ? I had probelms getting it to work with matchbox when I first looked at CI but not sure if there is better methods.

Have got Freaky_Auth and this library working but models etc are starting to pile up now and would like to use a modules library
#67

[eluser]Colin Williams[/eluser]
All Template ever does is call the view() method of the Loader class

Code:
$this->load->view($this->master, $this->output);
// $this->master is a filename relative to application/views, just as Views are traditionally accessed

If a "modules" solution has broken the default functionality of the Load::view() method, that's a serious flaw of that "solution." That said, I would love for Template to work with these modular-separation type libraries, so if anyone with more experience in those could provide insight into how they screw-up views loading (or don't do enough to keep the API standard), I'm all ears.
#68

[eluser]calingrim[/eluser]
Hello,
I am sorry if this was answered before but I coudn't find it.

So here goes nothing...

I got a controller:

Code:
class main extends Controller {
function main() {
  parent::Controller();
}

function index() {
  $this->template->write_view('header', 'files/header');
  $this->template->write_view('content', 'files/content');
  $this->template->write_view('footer', 'files/footer');
  
  $this->template->render();
}

function change() {
  $this->template->write_view('content', 'files/changeContent');
  $this->template->render();
}
}

And the view file:
Code:
<?=$header?>
<?=$content?>
<?=footer?>

Now the problem is that when i go to localhost/index.php/main/change it loads only the changeContent.php no more header or footer. Can anyone tell me how to do it please?

Thanks in advance.
#69

[eluser]opel[/eluser]
you either have to set

function index() {
$this->template->write_view('header', 'files/header');
$this->template->write_view('content', 'files/changeContent');
$this->template->write_view('footer', 'files/footer');

$this->template->render();
}

or in your config file you can set it as a default, if you look in the Template user guide
#70

[eluser]calingrim[/eluser]
[quote author="Opel" date="1222455952"]you either have to set

function index() {
$this->template->write_view('header', 'files/header');
$this->template->write_view('content', 'files/changeContent');
$this->template->write_view('footer', 'files/footer');

$this->template->render();
}

or in your config file you can set it as a default, if you look in the Template user guide[/quote]

So you are telling me that if I have a controller named main.php
Code:
function index() {
  $data['query'] = $this->db->get('a_table');

  /* and much more code here */
  
  $this->template->write_view('header', 'files/header', $data);
  $this->template->write_view('content', 'files/content');
  $this->template->write_view('footer', 'files/footer');
  
  $this->template->render();
}

I will have to write everything in a new controller named changeContent.php? Like this:

Code:
function index() {
  $data['query'] = $this->db->get('a_table');

  /* and much more code here */
  
  $this->template->write_view('header', 'files/header', $data);
  $this->template->write_view('content', 'files/changeContent');
  $this->template->write_view('footer', 'files/footer');
  
  $this->template->render();
}
?




Theme © iAndrew 2016 - Forum software by © MyBB