CodeIgniter Forums
Template Library Version 1.4.1 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Template Library Version 1.4.1 (/showthread.php?tid=12840)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24


Template Library Version 1.4.1 - El Forum - 11-12-2010

[eluser]Unknown[/eluser]
I didn't seam to make the add_js() work with a javascript hosted on another server (e.g. google hosted jQuery). I could be missing something here, but in case I'm not, I would like to share the change I've made. It's almost nothing, but it's good to keep it in mind for the next release.

I've attached the modified version of the 'libraries/Template.php' file (zipped, because the forum doesn't accept the php file even if I rename it) to keep this post small, but also because it was easier to present the context where the changes were made.
The changes are marked by 2 blocks that start with "Modification of the original code".


Template Library Version 1.4.1 - El Forum - 11-29-2010

[eluser]Stjepan[/eluser]
I jut started using this lib and i must say it's really really great.

My site is using 2 templates (depends on url you visit) and i'm i need to write somewhere on site: "you are using xxxxx template".

Is it possible to access active template name somehow?


Template Library Version 1.4.1 - El Forum - 12-10-2010

[eluser]codeninja[/eluser]
I am trying to use php-liquid as a parser .. but I am having a hard time in just adding it to the existing cycle..

when I call $this->template->write_view("region", "viewfile"); I want it to pass it through liquid rendering as well..

any ideas?

php-liquid can be found at: https://github.com/m3talsmith/php-liquid


Template Library Version 1.4.1 - El Forum - 12-15-2010

[eluser]firebird[/eluser]
Hi I am new to CI and I've just installed the Template Lib 1.4.1, and follow the document step by step, after I added two lines at the bottom of the file config/template.php:

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

and when I run it from the browser I always get this Error:

An Error Was Encountered

The "header" region has already been defined.


I can't figure out what caused the problem? can any expert here to give a comment?


Template Library Version 1.4.1 - El Forum - 12-21-2010

[eluser]nhanco[/eluser]
How can i admin other master template for my admin panel ?


Template Library Version 1.4.1 - El Forum - 12-27-2010

[eluser]Ray Nara[/eluser]
hi colin , how i can use with modular extension

i'm use modular extension from Phil Sturgeon


Template Library Version 1.4.1 - El Forum - 12-29-2010

[eluser]Evollution[/eluser]
Hi i am using CI 2.0 but when i try to add your library it doesnt work :

1)I uploaded you files
2)Edited config/template.php to

Code:
$template['default']['template'] = 'template';
$template['default']['regions'] = array(
  'header',
  'title',
  'content',
  'sidebar',
  'footer',
);
$template['default']['parser'] = 'parser';
$template['default']['parser_method'] = 'parse';
$template['default']['parse_template'] = FALSE;
$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>'));

3) edited view/template.php to
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) created main.php (controller)
Code:
&lt;?php
class Page extends CI_Controller {
  
function __construct()
    {
    parent::__construct();

    }

  
   function index()
   {
      // Write to $title
      $this->template->write('title', 'Welcome to the Template Library Docs!');
      
      // Write to $content
      $this->template->write_view('content', 'post');
      
      // Write to $sidebar
      $this->template->write_view('sidebar', 'common/sidebar');
      
      // Render the template
      $this->template->render();
   }
  
}
?&gt;

and know when i try to open http://www.fifago.com/demo2/index.php/main i get a 404 error why ?!


Template Library Version 1.4.1 - El Forum - 12-29-2010

[eluser]Evollution[/eluser]
sorry for poor english


Template Library Version 1.4.1 - El Forum - 12-29-2010

[eluser]WanWizard[/eluser]
You're getting a CI 404 error, which means CI can't find your main controller. Which according to your post is called 'Page'.

That is not going to work, filename and class name needs to be the same, with filename in lower case, and class with a capital first letter.


Template Library Version 1.4.1 - El Forum - 12-29-2010

[eluser]Sinclair[/eluser]
Hi,

I'm starting with this wonderful library and I have some doubts.

Here is my template:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /&gt;
&lt;title&gt;layout basic method web&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="&lt;?php echo base_url(); ?&gt;css/main.css" /&gt;
&lt;/head&gt;
&lt;body&gt;
<div id="head">
    <div class="pad1"></div>&lt;?php print $head; ?&gt;
</div>
<div id="content">
<div class="pad2"></div>
    &lt;IFRAME name="&lt;?php print $content_name; ?&gt;" src="http://www.google.com" width="100%" height="100%" frameborder=0&gt;&lt;/IFRAME>
<div class="pad2"></div>
</div>
<div id="foot">Footer</div>
&lt;/body&gt;
&lt;/html&gt;

Here is my config for the template:
Code:
## "template_web_page.php" Template Begin
$template['web_page']['template'] = 'template_web_page.php';

$template['web_page']['regions'] = array(
  'head' => array('content' => array('<h1>isto e o header do web page</h1>')),
  'title',
  'content',
  'content_name',
  'footer'
);

//$template['web_page']['regions']['head'] = array('content' => array('<h1>isto e o Header do web</h1>'));
## "template_web_page.php" Template End

And here is my controller:
Code:
&lt;?php

class Web extends Controller {

    function Web()
    {
        parent::Controller();
        $this->load->helper('url');        
    }
    
    function index()
    {
        $nome_site = "google";
        $url_site  = "http://www.google.pt";
        
        $this->template->write('content_name', 'You one ');
        $this->template->set_template('web_page');
        $this->template->render();
    }
}

I have got this error:
Quote:An Error Was Encountered

Cannot write to the 'content_name' region. The region is undefined.

My question. What can I do to write to 'content_name'. What is wrong in the template configuration?

Sorry the extend of all this code.


Best Regards,