multiple views per controller

#11
[eluser]Jason Bullard[/eluser]
[quote author="Derek Allard" date="1200715009"]Allow me to introduce one of the most requested features of our view output. Multiple views.

Code:
<?php

class Page extends Controller {

function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
$this->load->view('footer');
}

}
?>

Available now in an SVN near you... please test it out.[/quote]

I am running CI v.1.5.4 but this does not work. I have basically taken the above and changed the different view names to my own but it does not seem to work. The views are there and everything is properly configured but for some reason it still does not work.

I am just wondering if there is something specific I need to change in the config files.

TIA,
Jason

#12
[eluser]axle_foley00[/eluser]
[quote author="Jason Bullard" date="1201084263"][quote author="Derek Allard" date="1200715009"]Allow me to introduce one of the most requested features of our view output. Multiple views.

Code:
<?php

class Page extends Controller {

function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
$this->load->view('footer');
}

}
?>

Available now in an SVN near you... please test it out.[/quote]

I am running CI v.1.5.4 but this does not work. I have basically taken the above and changed the different view names to my own but it does not seem to work. The views are there and everything is properly configured but for some reason it still does not work.

I am just wondering if there is something specific I need to change in the config files.

TIA,
Jason[/quote]

Jason:

This isn't available in 1.5.4. You'd need to get version 1.6.0 beta from the SVN repository. Smile

#13
[eluser]Jason Bullard[/eluser]
Doh... Guess I should have read the "SVN" part huh. LOL. That is all good though. Smile

#14
[eluser]axle_foley00[/eluser]
lol Jason, it happens to the best of us.

Now I need to hurry up and test out the multiple views. Read about it last night in the docs but didn't try it at the time.

#15
[eluser]E1M2[/eluser]
Didn't see this in the changelog.

Exactly what I wanted to hear -- native support for multiple views.

This is timely, was originally going to use CF's View Library.

#16
[eluser]SneakyDave[/eluser]
This addition works great, but with this version from subversion, I can't get any database connectivity, it just tells me "An error was encountered". I'll have to downgrade and find "the old way" to use multiple views.

#17
[eluser]Michael Wales[/eluser]
Quote:This addition works great, but with this version from subversion, I can’t get any database connectivity, it just tells me “An error was encountered”. I’ll have to downgrade and find “the old way” to use multiple views.

You shouldn't have to downgrade. I am running the latest SVN loading multiple views "the old way." The latest SVN has no issues with database connectivity, and surely not because of native multiple view support.

#18
[eluser]ScottBruin[/eluser]
[quote author="Michael Wales" date="1200783156"]inparo - No offense taken. To be honest, I haven't tested it either (although I will be today as I start work on a new project). I'm PHP5 exlusive though. If you are as well - just use a real destructor rather than the ghetto-one, I'm pretty sure that would work.[/quote]

In my experience, using the PHP5 destructor will not work. The object is released before the destructor runs. So, $this->load-view('') no longer means anything because the CI object has been released.

#19
[eluser][email protected] Users Group in Japan[/eluser]
Hi, Derek
I was coding this like CakePHP using CI,

Code:
class Sample extends Controller {
function index()
{
$data['title'] = 'sample';
$data['contents'] = 'this is a layout template.';
$data['header'] = $this->load->view('parts/header', $data, TRUE);
$data['main'] = $this->load->view('parts/main', $data, TRUE);
$data['footer'] = $this->load->view('parts/footer', '', TRUE);
$this->load->view('layout', $data);
}
}
?>

layout.php
Code:
<?=$header?>
<?=$main?>
<?=$footer?>

But, Using new multiple views,
Code:
<?php

class Page extends Controller {

function index()
{
$data['page_title'] = 'Your title';
$this->load->view('header');
$this->load->view('menu');
$this->load->view('content', $data);
$this->load->view('footer');
}

}
?>

How should we use this(TRUE/FALSE)?

Code:
$this->load->view('view', $data, TRUE);

I think that this meaning has nothing.

Thanks

#20
[eluser]Derek Allard[/eluser]
bossatama, you can still use TRUE if you want a view returned as a string... but there is no need to do so for most standard page loads. For example, if you're using a view to generate a file for download or something, then you'd still want to use TRUE. I do this for PDF generation in BambooInvoice.

Have you found that something has broken for you, or is this more just a question?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.