Template Library Version 1.4.1 - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Template Library Version 1.4.1 (/showthread.php?tid=12840) |
Template Library Version 1.4.1 - El Forum - 12-27-2009 [eluser]developer10[/eluser] [quote author="2think" date="1261899393"]cold_fusion, I can't speak exactly about the 1.7.2 compatibility but this Template Library has default content capabilities for specific regions. If I remember correctly, it is in section III of the user guide, that might be exactly what you're looking for. Hope this helps some.[/quote] well, i think that might be just what i want. thanks for pointing that out! but still there's the issue of compatibility with 1.7.2. i dont want to start the implementation before somebody assures me that it's fully compatible Template Library Version 1.4.1 - El Forum - 12-27-2009 [eluser]AgentPhoenix[/eluser] I'm using the Template Library with 1.7.2 without any issues. Template Library Version 1.4.1 - El Forum - 12-30-2009 [eluser]razzatrox[/eluser] Please help. I'm following the user guide and getting this error: | |An Error Was Encountered | |The "header" region has already been defined. | All I did was load the library in the default controller's constructor The message comes from the "add_region" function when I include the prescribed lines in the config file: $template['default']['regions'] = array( 'header', 'title', 'content', 'sidebar', 'footer', ); $template['default']['regions']['header'] = array('content' => array('<h1>CI Rocks!</h1>')); $template['default']['regions']['footer'] = array('content' => array('<p id="copyright">© Our Company Inc.</p>')); Thanks Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]mrbinky3000[/eluser] Greetings, Love the template library. It is very handy! One question though. I seem to have problems when using the add_css and add_js utilities. Namely, nothing happens! Also, CI says that $_styles and $_script are undefined. I wrote overloaded the Controller class with My_Controller so that template can be called automatically on every page. I then overwrite the regions as necessary in each individual controller class method. I also render the template as the last line of every controller class method. If I call add_css in a controller, nothing happens. Is that because I already started writing regions in My_Controller? Would appreciate any advice. Thanks! Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]2think[/eluser] Hi mrbinky3000, I don't see why you would need to extend the Controller class with your own just to load the template library? I can't comment that it is wrong but do know you could simply use the config/autoload.php file and load the library there. http://ellislab.com/codeigniter/user-guide/general/autoloader.html. It will still get called on every page and thereafter, you merely need to do some $this->template->write or $this->template->write_view depending on what you may be passing in. Finalize all that as you already are with the $this->template->render() and it should work. Regarding your add_css and add_js utilities, you may want to check your paths relative to your index.php file. Also, check your .htaccess. I know those were two stumbling blocks for me when I setup Template but it's a very well-written library and user guide. Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]wmrobmuadib[/eluser] Hey Colin, everyone. Great library, running into snag switching template. In my template config I have 2 template groups defined Code: $template['active_template'] = 'tpl_main'; things work fine with main template writing my view in cotroller, however getting an error with controller trying to switch template Fatal error: Call to undefined function set_template(). Happens whether I call template library in autoload/constructor or index. Code: public function index() { anybody know what problem is? thx Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]mrbinky3000[/eluser] Let me clarify. I do load the template class in autoload.php. I overloaded the Controller class with the My_Controller class so that I could do the following in the MY_Controller constructor: Code: // load the default template Then, in each new Controller class that I create, I usually just overwrite the default body with a new view dedicated to that controller. For example: Code: class Hello extends MY_Controller Hopefully that clarifies things. Thanks! Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]2think[/eluser] wmrobmuadib, You're calling it as $this->template>set_template('tpl_adform') when you define it as $template['tpl_2'] Template Library Version 1.4.1 - El Forum - 12-31-2009 [eluser]wmrobmuadib[/eluser] [quote author="2think" date="1262315365"]wmrobmuadib, You're calling it as $this->template>set_template('tpl_adform') when you define it as $template['tpl_2'][/quote] Ooops, sorry. I just changed the name for my example to tpl_2 it's all the same 'tpl_adform' in my code Sorry, was 'sanitizing' my code, missed that one. it is consistent naming between config/ and adsignup.php controller $this->template>set_template('tpl_adform') when you define it as $template['tpl_2'] still not sure what issue. I noticed a discrepancy in the config file In the template.php config, the code is $template['active_template'] ='default'; while in user guide it lists it as $template['active_group']. Also noticed I had text error in code. I added the $template['active_group'] definition and now it works, thanks for your interest/help. Rob (now to debug next problem ) Template Library Version 1.4.1 - El Forum - 02-06-2010 [eluser]Unknown[/eluser] Is it me or does seem too crumby to actually send variables to your template? Why does everything have to be defined in a region? The page could have tens of variables, I can't sit there and add every region then write what I want to every region. Before I continue further ranting about my problem, let me explain what I'm trying to do. Have a global template with my default javascript, css, etc. with a <div> or <td> in that will contain every page. with write_view() I can pass the tpl file I want to include in that specific page, and also use the handy add_js/css() functions for any additional page-specific script or styles. so let's say I wrote write_view('include_tpl','index.tpl'). What if my index.tpl needs a variable {$name} to be passed to it. How can I do that? do I have to dynamically add a region then write that variable to that region? with smarty+php I would do the following: Code: $smarty->assign('name',"John Doe"); it would render index.tpl and put it in a smarty include line inside global.tpl Code: {include file="$_TPL_NAME_"} simple and easy. no regions. no hassle. If no one else has any better ideas, I'm at a point where I'm going to add a wrapper function to create a region and assign a value to it. And also instead of passing the included tpl file name with this new function, I'm going to modify render() to take a tpl file name and use that function automatically. My Final code would look like this Code: $user_name = "some guy"; instead of Code: $user_name = "some guy"; Cuts the code down by more than half! Will be waiting for your feedback. Dan |