Part of the EllisLab Network
   
13 of 15
13
Template Library Version 1.4
Posted: 23 November 2008 08:40 AM   [ Ignore ]   [ # 121 ]  
Summer Student
Avatar
Total Posts:  22
Joined  09-17-2008

I find the cause that got a empty page in IE7.

//use the chinese char title
    
$this->template->write('web_title','我是標題',TRUE);
//render
    
$this->template->render(); 

the chinese char!!!  shut eye

and It only happened on some chars,like the char ‘我’
but It working well on some chars,like the char ‘我的’

I don’t know why that don’t happened in Firefox.

Is encode problem? mad

but all my documents are utf-8 encode. confused

well…it’s a IE problem again? rolleyes

 Signature 

http://doublekai.org/blog/

Profile
 
 
Posted: 23 November 2008 04:08 PM   [ Ignore ]   [ # 122 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  112
Joined  02-13-2008

Do you use Output Compression ?
Check your config in config/config.php on line 275

 Signature 

Sorry for my pour english :(

Profile
 
 
Posted: 23 November 2008 08:17 PM   [ Ignore ]   [ # 123 ]  
Summer Student
Avatar
Total Posts:  22
Joined  09-17-2008

I check it be set:

$config['compress_output'FALSE 

now,I try clean all IE7 cookie,temporary and use ctrl + F5 to reload page
(I’m sure that no use any cache before)

confused but still happened

[CodeIgniter1.7]
[Template1.4.1]

controll:

class Welcome extends Controller {
    
public function Welcome ()
    
{
        parent
::Controller();
        
$this->load->library('Template');
    
}
    
public function index()
    
{
        $this
->template->write('web_title','我',TRUE);
        
$this->template->render();
    
}

view:

<html>
    <
head>
        <
meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <
title><?$web_title?></title>
    </
head>
    <
body>
        
//output something
    
</body>
</
html
 Signature 

http://doublekai.org/blog/

Profile
 
 
Posted: 17 December 2008 05:57 PM   [ Ignore ]   [ # 124 ]  
Summer Student
Total Posts:  10
Joined  12-17-2008

Colin—great library. Thank you for putting it together.

I’m a chain monkey. Like this:

$this->template->write_view('content''app_edit'$data)->render(); 

I don’t know if it’s affects PHP4 users, but if you return $this at the end of methods like write_view, you enable those of us using PHP5 to chain. Just a suggestion!

function write_view($region$view$data NULL$overwrite FALSE)
   
{
      $args 
func_get_args();
      
      
// Get rid of non-views
      
unset($args[0]$args[2]$args[3]);
      
      
// Do we have more view suggestions?
      
if (count($args) > 1)
      
{
         
foreach ($args as $suggestion)
         
{
            
if (file_exists(APPPATH .'views/'$suggestion EXT) or file_exists(APPPATH .'views/'$suggestion))
            
{
               
// Just change the $view arg so the rest of our method works as normal
               
$view $suggestion;
               break;
            
}
         }
      }
      
      $content 
$this->CI->load->view($view$dataTRUE);
      
$this->write($region$content$overwrite);
      return 
$this;

   
Profile
 
 
Posted: 17 December 2008 05:59 PM   [ Ignore ]   [ # 125 ]  
Summer Student
Total Posts:  10
Joined  12-17-2008

Big DRY fan here.

Not sure if it’s been mentioned here, but a quick tip for folks that are rendering the same chunk for every page in the controller. Instead of duplicating it for each method, you can dump the write_view in the Object init part of the Controller. When you render, the code chunk will appear.

Like this:

function App() {
        parent
::Controller();
        
$this->load->model('Userapps_model');
        
$this->load->library("template");
        
$data['app_list'$this->Userapps_model->getAllApps23 );
        
$this->template->write_view('app_listing''p_app_list'$data);
    
Profile
 
 
Posted: 19 December 2008 08:37 AM   [ Ignore ]   [ # 126 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  727
Joined  08-03-2006

Returning $this from a method does not affect PHP 4 at all (but make it a reference, in case someone using PHP 4 uses it).

PHP 4 chaining raspberry :

$t =& $this->template->write_view('something');
$t->write_view('something_else');
$t->render(); 
 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
 
 
Posted: 07 May 2009 12:50 PM   [ Ignore ]   [ # 127 ]  
Summer Student
Avatar
Total Posts:  22
Joined  04-23-2009

I have a site which has a number of “blocks” in the side bar. These blocks are just like the main view, they have a header & content that are constant location with every block. How do i load a seperate templated view within the main templated view??

 Signature 

Oliver Morgan
CIO Freshinc Solutions LTD

Looking for a project partner

Profile
 
 
Posted: 07 May 2009 01:03 PM   [ Ignore ]   [ # 128 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  272
Joined  08-07-2007

I have a front end class that I load in sideblock as separate functions e.g.

function navigation()
      {
        $this->navigation[‘navigation’] = array(“Home”, “Test”, “contact”);
        $this->data[‘frontend_navigation’] = $this->load->view (‘base/inc_navigation’, $this->navigation, TRUE);
      }

then put frontend navigation in my master template with a if statement to only show if required

 Signature 

Portfolio: Portfolio
Twitter: @gunkdesign

Profile
 
 
Posted: 29 September 2009 03:58 PM   [ Ignore ]   [ # 129 ]  
Summer Student
Total Posts:  3
Joined  06-13-2009

Hello!
Thank you for great library smile
However i got a small problem.

I have a set of regions like this
$template[‘default’][‘regions’] = array(
  ‘title’,
  ‘header’,
  ‘menu’,
  ‘content’
);

And i have 2 controllers:
1)In controller#1 i`m setting all regions and content region by write_view method.
Content view in this case is smth like:
“bla bla bla some content”
2)In controller#2 content region must contain some subregions.
For example view for content in this case is:
“bla bla bla <?=$another_region?>”

No problem with controller#1.
But for controller#2 i can`t define dynamic region.
$this->template->write_view(‘content’, ‘content_with_another_region’);
$this->template->add_region(‘another_region’);
$this->template->write_view(‘another_region’, ‘another_region_view’);

And i`v got undef variable error :(
I hope you understand my problem.

Am i wrong at somewhere??

Thank you smile

Profile
 
 
Posted: 30 September 2009 08:19 AM   [ Ignore ]   [ # 130 ]  
Lab Assistant
RankRank
Total Posts:  177
Joined  03-27-2008

The example you give makes it sound like you’re trying to call a variable in your view file that triggers a second view being written, but if you haven’t defined that variable, then you’d be getting that error. Your best bet is probably to parse the subregion content in your controller and append it to the end of your main content region.

$data['subregion'$this->parser->parse('subregion_view_file'$subdataTRUE); 

From there, you could just pass $data to your view like normal, but in your view file, echo out $subregion wherever you want it. If you’re using a single view file, you can even create a check to see if the variable exists and then echo it out. I think that’ll be the easiest way of doing it without adding the subregion to the Template config file, though Colin may have more insight and better ways of doing things.

Profile
 
 
   
13 of 15
13