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

[eluser]jpi[/eluser]
Hi,
Great library, I am using it in every projet. Thanks a lot.

I have a tiny request. I think you should change the way this library loads its config file
Code:
// Load the template config file and setup our master template and regions
include(APPPATH.'config/template'.EXT);

if (isset($template))
{
  $this->config = $template;
  $this->set_template($template['active_template']);
I propose this :
Code:
$this->CI->config->load('template', TRUE);
if (is_array(or !empty)($this->CI->config->item('template')) {
  $this->config = $this->CI->config->item('template');
  $this->set_template($this->config['active_template']);
Using CI config loader gives us three good things :
* It logs the action (useful for debugging)
* It triggers an error if the file is not found
* It adds a value in $this->config->is_loaded array which is useful for other library built on your template library.

What do you think ?

[eluser]Colin Williams[/eluser]
Well, despite that syntax being whack, I will consider it. One of my goals for the next release--coming soon--is better logging and error handling, so this might fit right in.

[eluser]satanrulehis[/eluser]
I'm newbie, can anyone makes a simple example ( with the menu on the left .... ) to download
Thanks alot

[eluser]Colin Williams[/eluser]
Template:
Code:
<html>
<body>

<div id="content">
&lt;?php print $content ?&gt;
</div>

<div id="sidebar">
&lt;?php print $sidebar ?&gt;
</div>

&lt;/body&gt;
&lt;/html&gt;

Controller code:
Code:
$this->template->write('content', 'Hello World!');
$this->template->write_view('sidebar', 'navigation');

[eluser]Staedtler[/eluser]
hi, i just started using ci and template lib, got a question .. can i send a data/variable in the main template ?

[eluser]Colin Williams[/eluser]
Quote:"My template uses other variables that aren't necessarily regions. How do I supply those within Template?"

You most likely will use variables in your main template that aren't content regions. For example, you might have a $body_id variable that you apply to the &lt;body&gt; element that you use in your CSS to apply styles to specific pages. This certainly could be a region, but it wouldn't quite fit the metaphor.

To supply these variables to your master template, use CodeIgniter's $this->load->vars() mechanism.

I didn't spend time on a user guide for nothing! Smile

[eluser]Staedtler[/eluser]
ooow, i miss that Tongue , thx

[eluser]Bramme[/eluser]
I've made a small adjustement to the add_js function:

I changed line 443 to
Code:
$filepath = strpos($script, 'http://') !== FALSE ? $script : base_url() . $script;

This allows me to easily link to external scripts, like google hosted jquery.

[eluser]meigwilym[/eluser]
Hi,

I extended the class so I could write meta data like this:
Code:
$this->template->add_meta('description', 'An example of a page description.');

so the meta tag would be written to the template via
Code:
echo $_meta;
I added this method to the class:

Code:
/**
    * Dynamically include meta tags in the template
    *
    * @param string $key meta name
    * @param string $value meta content
    * @return bool
    */
   function add_meta($key, $val)
   {
        $success = FALSE;
        $meta = '&lt;meta name="'.$key.'" content="'.$val.'" /&gt;';

        if(!in_array($meta, $this->meta))
        {
           $this->meta[] = $meta;
           $this->write('_meta', $meta);
           $success = TRUE;
        }

        return $success;

   }

and these other changes:
Code:
// added this to the class properties
var $regions = array(
  '_scripts' => array(),
  '_styles' => array(),
  '_meta' => array(),
);
var $meta = array();

// changed the array in template->set_regions() to
$this->regions = array(
  '_scripts' => array(),
  '_styles' => array(),
  '_meta' => array(),
);
I haven't trawled properly through the class so I'm not sure if all the above code is necessary.

If you have suggestions to improve this code please let me know.

Mei

[eluser]nsbingham[/eluser]
I'm running PHP 5.3 and CI 1.7.2 with only the Template library installed. No matter what I put in the Template config file I keep getting the error "Your template.php file does not appear to contain a valid configuration array." I've tried just using the example regions in the template file without luck. Does anyone have any suggestions on what might be wrong?

Update:

I was trying to autoload the library. Once I loaded it in the controller it worked.




Theme © iAndrew 2016 - Forum software by © MyBB