Welcome Guest, Not a member yet? Register   Sign In
Problem with use Template Library parser
#1

[eluser]Mahyar Ss[/eluser]
hi,

how can i use CI template parser with template library?

config/Template.php

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

$template['default']['parser'] = 'parser';
$template['default']['parser_method'] = 'parse';
$template['default']['parse_template'] = TRUE;


controllers/welcome.php
Code:
function __construct()
{
    parent::Controller();

        $this->load->library('parser');
}

function index()
{
        $data = array(
            'blog_title' => 'My Blog Title',
            'blog_heading' => 'My Blog Heading'
        );

        $this->template->parse_view('title', 'template', $data);

        $this->template->render();
}


views/template.php
Code:
{title}
Or
{blog_title}


no error but this not work !
and show in browser : {title}

what is wrong ?

please help

thnX
#2

[eluser]BrianDHall[/eluser]
http://ellislab.com/codeigniter/user-gui...arser.html

I'm not sure why you reference $this->template, and I'm unfamiliar with a parse_view() function...

What Template library are you trying to use?
#3

[eluser]Mahyar Ss[/eluser]
hi Brian,

"Template Library 1.4.1" is a template parser written for the CodeIgniter PHP-framework,

and i used for my application,

i need a multi template parser with ability "views within views" like something used PyroCMS...

What used PyroCMS for multi template?
#4

[eluser]Mahyar Ss[/eluser]
nobody know?
#5

[eluser]2think[/eluser]
Mahyar Ss,

If that really is your Template config file, I think I can point you in the direction to solve your problem.

1. The following entries/settings are only examples. If you were using Smarty or Dwoo or whatever, you would put those in there. That is, the name of the parser and also the method that PHP parser uses to parse files.

$template['default']['parser'] = 'parser';
$template['default']['parser_method'] = 'parse';

2. You need to load the 'template' library, not the 'parser' library. So change the following (I autoload the template library using the autoload.php file within application/config/ directory)
<pre>
function __construct()
{
parent::Controller();

$this->load->library('parser'); // this is wrong, you need to use ('template') but see my autoload suggestion above.
}


3. If you want, you can easily follow the excellent user guide on Colin Williams's site and it should give you a good grasp of the library without using a template parser. Then, if you choose, you can add the template parser functionality once you know your views within views work well. Just my suggestion.




Theme © iAndrew 2016 - Forum software by © MyBB