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

[eluser]Bramme[/eluser]
Okay, I'm having a weird problem. I've switched my online application to localhost for easier/faster development. I've adjusted the database.php and config.php files to work with my localhost settings, my template index is being loaded (I can see the mark up that's in it) however, there's nothing written to my regions. I didn't change anything and my logs even say

Code:
DEBUG - 2008-10-21 22:05:39 --> Controller Class Initialized
DEBUG - 2008-10-21 22:05:39 --> File loaded: C:\Users\Bram\Websites\ci-forum/system/application/views/ciforum/microviews/navigation.php
DEBUG - 2008-10-21 22:05:39 --> File loaded: C:\Users\Bram\Websites\ci-forum/system/application/views/ciforum/forum_overview.php
DEBUG - 2008-10-21 22:05:39 --> File loaded: C:\Users\Bram\Websites\ci-forum/system/application/views/ciforum/forum_index.php
DEBUG - 2008-10-21 22:05:39 --> Final output sent to browser
The render() process is clearly happening, as I can see the index page's content (some <hr>'s), but no region content.

Any ideas?


Oh wait, did change one thing! I switched from CI1.7.0 to 1.6.3

Right, didn't think about checking the page's source code. Just did so and I saw this:
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;link rel="shortcut icon" href="&lt;?= site_url() ?&gt;favicon.ico" /&gt;
    &lt;title&gt;CI-Forum&lt;/title&gt;
    &lt;link href="&lt;?= site_url() ?&gt;assets/css/reset.css" rel="stylesheet" /&gt;
    &lt;link href="&lt;?= site_url() ?&gt;assets/css/forum_style.css" rel="stylesheet" /&gt;
    &lt;?= $_scripts ?&gt;
    &lt;?= $_styles ?&gt;
&lt;/head&gt;

&lt;body&gt;
boe
&lt;?= $ciforum_usercontrol ?&gt;
<hr />
&lt;?= $ciforum_content ?&gt;
<hr />
&lt;?= $ciforum_footer ?&gt;

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

edit, stupid, short open tag wasn't enabled.

[eluser]dexcell[/eluser]
Hello i downloaded template library version 1.4 from your website (http://williamsconcepts.com/ci/codeignit...nload.html), but when i extract the zip file and see the template.php in library folder it still says version 1.2.

I wonder if this is the latest version, since i want to try this library Smile

Thank you

[eluser]Colin Williams[/eluser]
Sorry.. a lot of people have caught this.. You do have 1.4, not 1.2. Sorry for the mixup

[eluser]Colin Williams[/eluser]
Quote:I dont get what add_region does?
It doesnt seem to do anything?

Template takes a very strict approach with regions. When I originally wrote Template, if a write() method encountered a region that did not exist, it simply created the region at that point. This became troublesome when I would misspell regions at points. The content seemed to disappear! And Template gave no fuss. So, I made it so regions HAD TO be pre-defined. I also, however, realized how automatic creation of regions could be a feature, especially in a modular environment. Instead of configuring the problem away, I decided to write a whole suite of methods to modify the current template configuration. This way, regions can be added on the fly with intent. That's the key. The add_region() method is a way to force programmers to express the intent of adding a region.

So, it would be used like this:

Code:
$this->template->add_region('login');
$this->template->write_view('login', 'users/login');

Imagine, for the sake of argument, that code was part of a user module or plugin. Then, all a front-end programmer has to do is print $login in the template (without having to modify their region config).

[eluser]N Narayanan[/eluser]
Hi,

I have just started using Template Library version 1.4. It is very good. Thanks to Colin for his great job. Since I am a newbee I am missing the following,

a) Lets say that we have 4 regions (header, content, sidebar & footer)
b) I know how to define the regions in template.php under config folder (given as below)

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

c) What I am missing is where are we defining the Coordinates for these regions so that when we call the function write_view('sidebar', 'sidebar'); the output data exactly goes to the place where we wanted?

d) I assume that somewhere we have to define the html table, but dont know where we have to define

Can some one help me? Any code would be highly appreciated.

Regards
Narayanan

[eluser]Colin Williams[/eluser]
If a region is written 'A' then 'B' and finally 'C', the region will contain 'ABC'.

In other words, regions contents will appear in the order to which they are written.

Quote:I assume that somewhere we have to define the html table

Not sure what this means. God forbid, you are talking about laying out a page with a table. If so, you would have that table as part of your master template like this:

Code:
<table>
  <tr>
    <td colspan="2">&lt;?= $header ?&gt;</td>
  </tr>
  <tr>
    <td>&lt;?= $sidebar ?&gt;</td>
    <td>&lt;?= $content ?&gt;</td>
  </tr>
  <tr>
    <td colspan="2">&lt;?= $footer ?&gt;</td>
  </tr>
</table>

But this might be better

Code:
<div id="header">&lt;?= $header ?&gt;</div>
<div id="content">&lt;?= $content ?&gt;</div>
<div id="sidebar">&lt;?= $sidebar ?&gt;</div>
<div id="footer">&lt;?= $footer ?&gt;</div>

Then you can use CSS to layout the page visually.

[eluser]Colin Williams[/eluser]
Template 1.4.1 has been released.

[eluser]ardinotow[/eluser]
I have problem when trying to retrieve template name from config files to my controller.

Here is the details

I made little modification to the config file:
Code:
&lt;?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

$template['active_template'] = 'default';

$template['default']['name'] = 'mollio-D';
$template['default']['template'] = 'themes/'.$template['default']['name'].'/template';
$template['default']['regions'] = array(
   'header',
   'nav',
   'breadcrumb',
   'content',
   'sidebar',
   'footer',
);
$template['default']['parser'] = 'parser';
$template['default']['parser_method'] = 'parse';
$template['default']['parse_template'] = FALSE;


/* End of file template.php */
/* Location: ./system/application/config/template.php */

FYI, mollio-D is my theme name and also the directory name for my default template.

In my controller, I wrote this line:
Code:
&lt;?php

class Ads extends Controller {

    function Ads()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->config('template', TRUE);
        $tmpl_config = $this->config->item('template');
        $tmpl_name = $tmpl_config['default']['name'];
        $this->template->write_view('sidebar', 'themes/'.$tmpl_name.'/sidebar', '', TRUE);
        $this->template->render();
    }
}

/* End of file ads.php */
/* Location: ./system/application/controllers/ads.php */

Then I got this error when trying to load the page :
Code:
An Error Was Encountered

Your template.php file does not appear to contain a valid configuration array.

Can anyone solve this problem? Thx...

[eluser]Colin Williams[/eluser]
Template does not provide a $config array. It uses its own $template array. The Template class does maintain the $template array as a property, though, as well as the active template. So you can get at this name two ways:

Code:
$name = $this->template->config['default']['name'];
// OR, this one will have the current active template config
$name = $this->template->template['name'];

[eluser]ardinotow[/eluser]
[quote author="Colin Williams" date="1227062637"]Template does not provide a $config array. It uses its own $template array. The Template class does maintain the $template array as a property, though, as well as the active template. So you can get at this name two ways:

Code:
$name = $this->template->config['default']['name'];
// OR, this one will have the current active template config
$name = $this->template->template['name'];
[/quote]

Yeah, my problem is solved now. Thank you =)




Theme © iAndrew 2016 - Forum software by © MyBB