Welcome Guest, Not a member yet? Register   Sign In
Template Library Version 1.4

[eluser]sankai[/eluser]
I use the $this->template->render() to render my page.

It's working well in Firefox...

But,when I visit the page in IE7,it's a empty page,so I try click mouse right button to show the source code,it's be correct output!.

Do I ignore something?

[eluser]sankai[/eluser]
I find the cause that got a empty page in IE7.

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

the chinese char!!! Confusedhut:

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? >Sad

but all my documents are utf-8 encode. :-S

well...it's a IE problem again? :roll:

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

[eluser]sankai[/eluser]
I check it be set:
Code:
$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)

:-S but still happened

[CodeIgniter1.7]
[Template1.4.1]

controll:
Code:
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:
Code:
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?= $web_title?></title>
    </head>
    <body>
        //output something
    </body>
</html>

[eluser]BenJaminJ[/eluser]
Colin -- great library. Thank you for putting it together.

I'm a chain monkey. Like this:
Code:
$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!

Code:
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, $data, TRUE);
      $this->write($region, $content, $overwrite);
      return $this;

   }

[eluser]BenJaminJ[/eluser]
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:

Code:
function App() {
        parent::Controller();
        $this->load->model('Userapps_model');
        $this->load->library("template");
        $data['app_list'] = $this->Userapps_model->getAllApps( 23 );
        $this->template->write_view('app_listing', 'p_app_list', $data);
    }

[eluser]m4rw3r[/eluser]
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 Tongue :
Code:
$t =& $this->template->write_view('something');
$t->write_view('something_else');
$t->render();

[eluser]Freshinc.Olly[/eluser]
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??

[eluser]opel[/eluser]
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

[eluser]pnd_ku[/eluser]
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 Sad
I hope you understand my problem.

Am i wrong at somewhere??

Thank you Smile




Theme © iAndrew 2016 - Forum software by © MyBB