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

[eluser]wildarp[/eluser]
Good day. I have some problem, I can not ot get work the Template library with Authentication Library ( http://www.adamgriffiths.co.uk/user_guide/ ), somebody can tell how to make it work together.

[eluser]JayTee[/eluser]
Not a huge deal... but the URL to your website in the library is broken; it works in your signature just fine Smile

[eluser]Colin Williams[/eluser]
I have had other reported problems in 1.7.2. I will try to release a new version soon that works better with 1.7.2 (and thanks for the catch, JayTee).

Try putting the library in your system folder. I have a feeling it has to do with the fact that the class is prefixed with "CI_" like other core classes. This has many benefits, but if 1.7.2 breaks it, I might have to ignore the benefits for the sake of compatibility/usability.

[eluser]dinhtrung[/eluser]
I tried to patch Template class for CI object style. After the patch, we can use:
Code:
function template()
{
    $this->load->library('template');
        $this->template->write('header', "Say Hello to the Template Library")
            ->write('footer', "Copyright by Nguyen Dinh Trung")
            ->write_view('content', 'sample')
            ->render();
}
Much nicer, isn't it?

[eluser]Unknown[/eluser]
Hello,

I'm trying to use your library with the recent CI (1.7.2) using IIS 7.0 and FastCGI module installed. CI itself runs perfectly but I have some problems using your library.
This is what I have done (copied some from your tutorial):

1. config/template.php
Code:
$template['default']['template'] = 'blog_template.php';
$template['default']['regions'] = array(
  'title',
  'content',
  'sidebar',

);

$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>'));


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

2. views/blog_template.php
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;

3. controllers/blog
Code:
&lt;?php

class Blog extends Controller
{
    function __construct()
    {
        parent::__construct();

        $this->load->helper('url');
        $this->load->library('tank_auth');
    }

    function index()
   {
       $this->template->write('title', 'Hello world!');
       $this->template->write_view('content', 'welcome');
       $this->template->render();
   }
}
?&gt;

And output page is absolutely empty! When I comment all the code and use $this->load->view('welcome'), everything's working fine but your functions are not working properly. Can you please tell me what I'm doing wrong?
Thank you.

UPD: By the way, when I remove all the code from index() function and leave only render(), it renders empty template to browser.

[eluser]Unknown[/eluser]
Hi, how do i load a template within a template?

for example i have a controller/welcome.php:

Code:
....
function index()
   {
      // Write to $title
      $this->template->write('title', 'THIS IS MY TITLE');
      
    
      // Write to $content
      $this->template->write_view('format', 'full_view');

      //  $this->template->write_view('content', 'welcome_view');
  

      // Render the template
      $this->template->render();
   }

and the views/full_view.php contains:

Code:
<div>
&lt;?= $content;?&gt;
</div>

how can i write to the $content region to write another view? When i try $this->template->write_view('content', 'welcome_view'); I get an error saying content is an undefined variable. Or is there another way i should structure my code and view files?

Cheers

[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

[eluser]developer10[/eluser]
hi, have a few questions about this library

first of all, there are some things i dont like much about CI - and hopefully this template will allow me to get rid of that

for example, i have a simple search form in my header, which is shown on every page of my site (so a user can access it easily).

there are two drop-down boxes in it, so there's some code i have to include in every controller i create, in order to show the form properly

now, what i want to do is to make things simpler - i want that code (and all of the code of a specific sections of the site which will be repeated)
to be automatically included when i call my main template.
that means i wouldn't have to add this

Code:
$data['form_att'] = array('class'=>'frmSrc','id'=>'frmSrc');
        $data['submit_att'] = array('class'=>'mySubmit');
        $data['dropdown_djelatnosti'] = $this->Front_model->getdropdown_djelatnosti_array('d_seo', 'djelatnost', 'tbl_djelatnosti');
        $data['dropdown_gradovi'] = $this->Front_model->getdropdown_gradovi_array('_F_GRAD', '_F_GRAD', '_tbl_firme');

in every single controller i create.

is this possible with your template?

ONE MORE IMPORTANT QUESTION: is this library fully ready for use with the latest version of CI (1.7.2)? will you continue to develop it
in the future (at least, to the level it works with future versions of CI)?

[eluser]2think[/eluser]
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.

[eluser]Mahyar Ss[/eluser]
Nobody can help me? Please...

Post[ # 116 ]




Theme © iAndrew 2016 - Forum software by © MyBB