Part of the EllisLab Network
   
1 of 2
1
Template Library Version 1.3
Posted: 16 August 2008 07:28 PM   [ Ignore ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Template Library Version 1.3 has been released. Version 1.3 adds new features for working with template parsers like Smarty.

——————————————————————————————————————————-

Visit the Template Library Homepage

View the Change Log

Still using Template 1.2.1? See the Ignited Code thread covering Template 1.2.1

——————————————————————————————————————————-

What’s New in Version 1.3?

Since Version 1.1, Template provided the parse_view() method, allowing programmers to utilize CI’s Template Parser class when writing to regions instead of just using standard PHP-coded Views. Version 1.3 expands this functionality, allowing the use of any additional template parser, like the popular Smarty Template Engine. Along these same lines, Version 1.3 allows the master template file to be parsed by any parser class instead of always being loaded as a View.

——————————————————————————————————————————-

The Template library, written for the CodeIgniter PHP-framework, is a wrapper for CI’s View implementation. Template is a reaction to the numerous questions from the CI community regarding how one would display multiple views for one controller, and how to embed “views within views” in a standardized fashion. In addition, Template provides extra Views loading capabilities and shortcuts for including CSS, JavaScript, and other common elements in your final rendered HTML.

Using Template looks like this:

$this->template->write('title''Introduction to Template');
$this->template->write_view('content''blog/posts'$this->blog->get_posts());
$this->template->render(); 

Look interesting? Head over to the Template Library Homepage to begin using Template in your next CodeIgniter application.

 Signature 

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

Profile
 
 
Posted: 17 August 2008 01:26 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  03-27-2008

I love the idea of defining regions like Template does, but I noticed that it requires putting a master template into the config file. I’m developing an application where I need to be able to define the master template on the fly though. Any ideas how I might do that using something like Template?

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

@AgentPhoenix, Check out View Object (see my signature) it allows regions and sub-regions also. (there is a PHP4 version)

 Signature 

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

Profile
 
 
Posted: 17 August 2008 01:56 AM   [ Ignore ]   [ # 3 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Any ideas how I might do that using something like Template?

There is an add_template() method and set_template() method for this very instance, AgentPhoenix. Both are covered in the docs at:

http://williamsconcepts.com/ci/codeigniter/libraries/template/reference.html#manipulation

Essentially you do:

$new_template = array(
   
'template' => 'other_template.php',
   
'regions' => array('region1''region2''region3')
);
$this->template->add_template('name_it'$new_templateTRUE); 

Or, you can define more templates in the config file and do $this->template->set_template(‘name’);

Let me know if you need more info.

 Signature 

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

Profile
 
 
Posted: 17 August 2008 02:10 AM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  03-27-2008

Yeah, I saw the add_template() method, but for my app, I’m not a fan of having to do that in every constructor like that. I’d rather set the regions in the config file then set the master template on the fly (it’s based primarily on session variables and the like). Because of the fact that themes can be added to the application too, I’d like to avoid having users have to add a ton of stuff to the config file every single time they add a theme to the application.

Does that make sense or is the sleep deprivation going to my head? wink

Profile
 
 
Posted: 17 August 2008 02:14 AM   [ Ignore ]   [ # 5 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

Ah.. just do:

$this->template->master 'other_template';
// Does not need file extension unless it is other than '.php' 

It is a bit hackish, sure, but there is currently no specific method for this action (there was in a previous release). If you’d like, I’ll add a set_master_template() method and release it for you.

 Signature 

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

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

Well thank you very much Colin. I’ll be playing with the update over the next few days and get back to you smile

 Signature 

Milos Dakic

Profile
 
 
Posted: 17 August 2008 11:08 AM   [ Ignore ]   [ # 7 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  03-27-2008

So I can do the $this->template->master in each constructor? What do I put in the config file then? Having a method to set the master template would be awesome! Love the work you’ve done here, Colin. smile

Profile
 
 
Posted: 17 August 2008 03:27 PM   [ Ignore ]   [ # 8 ]  
Sr. Research Associate
Avatar
RankRankRankRankRank
Total Posts:  2774
Joined  07-27-2006

That’s right, AgentPhoenix. You can do it in every constructor to set it up for the respective controller. And if it happens across all controllers, perhaps do it in a post_controller_constructor hook. In the config file, just set $template[‘default’][‘template’] to something that will satisfy the initialize() method and not throw an error… like, just a default template, even if it’s a blank file, or better yet, a file with instructions for programmers to write their own template.

 Signature 

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

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

Template Version 1.4 has been released.

 Signature 

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

Profile
 
 
Posted: 10 September 2008 11:43 PM   [ Ignore ]   [ # 10 ]  
Summer Student
Total Posts:  1
Joined  08-14-2008

How i can implement paging using Template library?

Thanks..!!!!

Profile
 
 
   
1 of 2
1