Welcome Guest, Not a member yet? Register   Sign In
Phil Sturgeon Template library. Need help please
#1

[eluser]prashid[/eluser]
I have below code for a simple layout but in the browser I don't see the OUTPUT. I have

$config['rewrite_short_tags'] = TRUE;

Thanks in advance.

Code:
Config file at the end
<?php
function __autoload($class)
{
if(strpos($class, 'CI_') !== 0)
{
  @include_once( APPPATH . 'libraries/'. $class . EXT );
}
}
<?php

In Libraries folder
<?php
class  MY_Controller  extends  Controller  {

    function MY_Controller ()
    {
        parent::Controller();
    }
    }
?>    
<?php
class Public_Controller extends MY_Controller
{
    function __construct()
    {
       parent::MY_Controller();

        $this->load->library('template');
       $this->template->set_theme('default');
      
       //layout_test.html
        $this->template->set_layout('layout_test');
        $this->template->enable_parser(FALSE);
    }
}
?>

<?php
class Admin_Controller extends MY_Controller
{
    function __construct()
    {
       parent::__construct();
    }
}
?>
    
application/themes/default/views/layouts/layout_test.html
<!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;?= $template['title'] ?&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <div id="content">
            &lt;?= $template['body'] ?&gt;
        </div>
    &lt;/body&gt;
&lt;/html&gt;

application/views/my_view.php
&lt;html&gt;
    &lt;head&gt;
        &lt;title&gt;Hello Anyone&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
    &lt;/body&gt;
&lt;/html&gt;

Calling from Browser
&lt;?php

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

        $this->template->build('view_name');
        $this->template->title('Some title')->build('view_name');
    }
}
?&gt;
#2

[eluser]InsiteFX[/eluser]
turn off short tags in config.php and use &lt;?php echo $name; ?&gt; tags.

InsiteFX
#3

[eluser]prashid[/eluser]
Did whatever you said. Turned shot tags to FALSE But in browser I get ERROR

An Error Was Encountered
Unable to load the requested file: my_layout.php


I don't have my_layout.php but instead I have my_layout.html which contains below code

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;?php echo $template['title']; ?&gt;
    &lt;/head&gt;
    &lt;body&gt;
        <div id="content">
            &lt;?php echo $template['body']; ?&gt;
        </div>
    &lt;/body&gt;
&lt;/html&gt;
#4

[eluser]InsiteFX[/eluser]
Change the file extension from .html to .php
I think his library is looking for the .php
extension.

InsiteFX
#5

[eluser]prashid[/eluser]
Thanks for the help. Its working now.

2 questions.
What are partials and whats the best use of it and where to use it?
What should be in layouts(Overall skeleton of side and than with views to fill in the parts)?
#6

[eluser]InsiteFX[/eluser]
Quick answer I would download PyroCMS
and look at the code!

PyroCMS

InsiteFX
#7

[eluser]prashid[/eluser]
Thanks

I already been looking at it.I am not an advance user thats why asked.Any comments?




Theme © iAndrew 2016 - Forum software by © MyBB