Part of the EllisLab Network
   
2 of 15
2
Template Library Version 1.4
Posted: 24 August 2008 03:34 PM   [ Ignore ]   [ # 11 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Simply put, regions are not multidimensional. They don’t hold additional attributes like you’ve laid out here. Regions are just placeholders for content. That content can be generated in anyway you choose, but typically it is with Views.

If you need additional variables available to your master template that are not regions, use the tried and trusted $this->load->vars() method in CI.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 24 August 2008 06:31 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  133
Joined  06-06-2008

Can $this->load->vars() be used with other template parsers other then the default CI $this->load->view() or $this->parser->parse()?

 Signature 

Milos Dakic

Profile
 
 
Posted: 24 August 2008 06:41 PM   [ Ignore ]   [ # 13 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

This function takes an associative array as input and generates variables using the PHP extract function. This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might want to use this function independently is if you would like to set some global variables in the constructor of your controller and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached and merged into one array for conversion to variables.

Doesn’t say anything specific about the Template Parser class, but certainly covers Views. I don’t use template parsers ever so it’s not something I’ve come across. Should be easy enough to check.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 25 August 2008 04:54 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  133
Joined  06-06-2008
Colin Williams - 24 August 2008 10:41 PM

Doesn’t say anything specific about the Template Parser class, but certainly covers Views. I don’t use template parsers ever so it’s not something I’ve come across. Should be easy enough to check.

Yeah I don’t think it works. Unless I’m doing something wrong.

 Signature 

Milos Dakic

Profile
 
 
Posted: 25 August 2008 06:06 AM   [ Ignore ]   [ # 15 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  3216
Joined  06-10-2007

$this-load->vars() extracts your array of variables into the view buffer and is only available to $this->load->view(). Whereas the CI Parser relies on a specific $data array being passed to it.

Hope this helps.

 Signature 

URI Language Identifier | Modular Extensions - HMVC | View Object | Widget plugin | Access Control library

Profile
 
 
Posted: 25 August 2008 01:57 PM   [ Ignore ]   [ # 16 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Good to know, wiredesignz.

So, Milos, you just need to pass that data when writing the file to be parsed

$data = array('type' => 'classic''active' => 1);
$this->template->parse_view('region''parse/file'$data); 
 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 26 August 2008 05:16 AM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  133
Joined  06-06-2008

Thanks wiredesignz and Colin.

Could the variables be passes to Template? Would this be logical as Template is trying to keep to the CI standard as much as possible? If this is included in Template it would mean that if Template is removed from any solution and the user decides to go back to the CI standards $this->load->view() or $this->parser->parse() their solution would not need much changing.

Thanks for all the feedback. I think any suggestions will improve Template as a library.

 Signature 

Milos Dakic

Profile
 
 
Posted: 26 August 2008 05:25 AM   [ Ignore ]   [ # 18 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Keep your eye out for the next release, Milos. I think you’ll like what I come up with.

I still want to address the last part of your statement and stress that Template interfaces with views and parsers, it does not act like them. It is not a replacement for either of the two items.

 Signature 

Check out the Template Library
Oh yeah, I tweet, too (regarding CodeIgniter on occassion).

Profile
 
 
Posted: 26 August 2008 05:25 AM   [ Ignore ]   [ # 19 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  133
Joined  06-06-2008

Now I like the sound of this! smile Thanks Colin.

Colin Williams - 26 August 2008 09:25 AM

I still want to address the last part of your statement and stress that Template interfaces with views and parsers, it does not act like them. It is not a replacement for either of the two items.

Sorry, I don’t think I made it clear what I was trying to say. I understand it is NOT a replacement. I was trying to say that in a case where a user decides to remove Template from their solution it will be very simple for them to update their code to do so.

 Signature 

Milos Dakic

Profile
 
 
Posted: 02 September 2008 08:48 AM   [ Ignore ]   [ # 20 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

From what I can find in the code, it is not possible to set a view as default content of a region.

So I made a small addition to your lib, feel free to add it:

// in Template::add_region(), add this just before the closing bracket:
if(isset($props['view']))
{
     $this
->write_view($name$props['view']);

Then you can use it like this:

$template['default']['regions'= array(
     
'a_region' => array('view' => 'a/view')); 
 Signature 

RapidDataMapper: My new ORM, is now released!

IgnitedRecord: Old ORM

MPTtree: A model to handle trees in a database.

YAYParser - Yet Another YAML Parser

Profile
 
 
   
2 of 15
2