Part of the EllisLab Network
   
2 of 14
2
Template Library Version 1.4
Posted: 24 August 2008 02:34 PM   [ Ignore ]   [ # 11 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
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 05:31 PM   [ Ignore ]   [ # 12 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  131
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
JustHost - world class hosting
Library: Events Library

Profile
 
 
Posted: 24 August 2008 05:41 PM   [ Ignore ]   [ # 13 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
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 03:54 AM   [ Ignore ]   [ # 14 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  131
Joined  06-06-2008
Colin Williams - 24 August 2008 05: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
JustHost - world class hosting
Library: Events Library

Profile
 
 
Posted: 25 August 2008 05:06 AM   [ Ignore ]   [ # 15 ]  
Sr. Research Associate
RankRankRankRankRank
Total Posts:  2634
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 - PHP5 | Modular Separation - PHP5 | Widget plugin | Access Control library

Profile
 
 
Posted: 25 August 2008 12:57 PM   [ Ignore ]   [ # 16 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
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 04:16 AM   [ Ignore ]   [ # 17 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  131
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
JustHost - world class hosting
Library: Events Library

Profile
 
 
Posted: 26 August 2008 04:25 AM   [ Ignore ]   [ # 18 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2916
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 04:25 AM   [ Ignore ]   [ # 19 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  131
Joined  06-06-2008

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

Colin Williams - 26 August 2008 04: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
JustHost - world class hosting
Library: Events Library

Profile
 
 
Posted: 02 September 2008 07:48 AM   [ Ignore ]   [ # 20 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  740
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 14
2
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 119889 Total Logged-in Users: 60
Total Topics: 126031 Total Anonymous Users: 4
Total Replies: 663001 Total Guests: 467
Total Posts: 789032    
Members ( View Memberlist )