Welcome Guest, Not a member yet? Register   Sign In
Template library 1.4 problem
#1

[eluser]dannieWalden[/eluser]
Hey gurus.

I just started using the template library. i’ve followed the userguide several times to get i right, but i get following error:
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined property: Page::$parser

Filename: libraries/Template.php

Line Number: 574

Cant find out why?

Can anyone help me, please Wink


controller:
Code:
<?
class Page extends Controller {
  
   function Page()
   {
      parent::Controller();
   }
  
   function index()
   {
       $this->load->library('Template');  
      // Write to $title
      //$this->template->write('title', 'Welcome to the Template Library Docs!');
      
      // Write to $content
      //$this->template->write_view('content', 'main/login_form');
      
      // Write to $sidebar
      //$this->template->write_view('sidebar', '<h1>sidebar</h1>');
      
      // Render the template
      $this->template->render();
   }
  
}
?&gt;

configfile:
Code:
$template['active_group'] = 'default';
$template['default']['template'] = 'template.php';

$template['default']['regions'] = array(
    'header',
  'title',
  'content',
  'sidebar',
  'footer',
);




$template['default']['parse_template'] = TRUE;

templatefile:
Code:
&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;&lt;?= $title ?&gt;&lt;/title&gt;
      &lt;link rel="stylesheet" type="text/css" href="main.css" /&gt;
   &lt;/head&gt;
   &lt;body&gt;
      <div id="wrapper">
         <div id="header">
            &lt;?= $header ?&gt;
         </div>
         <div id="main">
            <div id="content">
               <h2>&lt;?= $title ?&gt;</h2>
               <div class="post">
                  &lt;?= $content ?&gt;
               </div>
            </div>
            <div id="sidebar">
               &lt;?= $sidebar ?&gt;
            </div>
         </div>
         <div id="footer">
            &lt;?= $footer ?&gt;
         </div>
      </div>
   &lt;/body&gt;
&lt;/html&gt;
#2

[eluser]triplethree[/eluser]
Hi Dannie.

It doesn't (from looking at your template file) look like you need to be using a parser. In you config file set parse_template to false rather then true.
Code:
$template['default']['parse_template'] = FALSE;

If you can, I'd always avoid php short tags. Some hosts don't allow them so it could cause you problems down the line. Instead use
Code:
&lt;?php echo $header; ?&gt;

Hope this helps.


Tom
#3

[eluser]syntax3rror[/eluser]
Thanks for this post..


I made my simple template works.

In this page Template Getting Stated didnt't mentioned to load.
Code:
$this->load->library('Template');




Theme © iAndrew 2016 - Forum software by © MyBB