• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Phil Sturgeon's Template Library?

Hello Phil and others Smile

I came with some problems here..

For example I have module, called 'categories'.

In the controller of this, module, I do:

I get the error:
Unable to locate the file: categories/topnav.php
But this file is located in:

Later I tried to put this file into:

- no such error, all works OK.

How I can make Module use a theme? or maybe it is not possible?

Thank you very much!

[eluser]Phil Sturgeon[/eluser]

[quote author="Phil Sturgeon" date="1271512588"]Application/themes/views/modules/modulename/whatever.php[/quote]

strange, but I can't get it to work...
(admin is theme name)
I did:

I tried:


-- nothing workedSad
my temalate.php config is the default one.

What I am trying to to, is that I need a little app, with and admin backend.
for heavier projects I use Pyro.
But I came to a solution, that it's a time to start using templates, it's cleaner, easier to adapt to new projects/designs.
I looked threw Pyro for examples, and started using Template Library

I have an example controller 'categories' (extending Admin_Controller) - admin.php
and one controller is extending Public_Controller - categories.php

these both files located in same directory:

now when I want for example build a 'form.php' view which is located at:

I have also this layout:

So when I do:
$this->template->build('form', $data);

Shouldn't it work?
Maybe I'm missleading you, and miss understanding something...
So I decided to describe whole problem...

Thank you!

Hi Devon,
I've been trying different ways of using Phil's library following the comments in this thread and playing with PyroCms with no success. Would you be so kind as to tell us how you made it work for you? I won't mind writing some documentation if I can make it work!

Just in case, here's what I've done:

1 - Dropped Template.php "system/application/libraries"
2 - Created a MY_Controller.php in "system/application/libraries" with the following code:

<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class MY_Controller extends Controller
    function __construct()
3 - Created a layout.php and placed it in "system/application/themes/default/views". layout.php has the following code:
        <title><?php echo $template['title']; ?></title>
        <?php echo $template['metadata']; ?>                    

        <div class="container">
        &lt;?php echo $template['body']; ?&gt;
        <div id="footer">Copyright 2010</div>
4 - And this is my welcome.php controller:
class Welcome extends Controller {

    function Welcome()
    function index()
    $data['saysomething'] = 'saysomething';
    $this->template->build('layout', $data);

Here's what I get:
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$template
Filename: controllers/welcome.php
Line Number: 19

Fine. Just in case I go and modify my welcome.php controller and add "$this->load->library('template');" just after "parent::Controller();". This is what I get:
Quote:An Error Was Encountered
Unable to locate the file: layout.php

[eluser]Phil Sturgeon[/eluser]
Application/themes/admin/views/modules/modulename/whatever.php should be fine.

"it doesn't work" is not very descriptive about the actual problem you are getting. Error messages? Screenshots?

Hi Phil, I've just updated my question with more information on how I'm using your library and the problems I'm finding.

[quote author="MrCevic" date="1272487877"]Hi Phil, I've just updated my question with more information on how I'm using your library and the problems I'm finding.[/quote]

I had similar problems as yours...
I have made some modifications to template.php library earlier...

Could you try my attached file and see if it helped you?


When you are setiing up layout as layout.php
you should later use: build('index.php') for example

and the content of 'build' you can get by:

putting: &lt;?php echo $template['body'];?&gt; in layout.php...

Just play with it, see PyroCMS examples Smile

Hi Hugle,

I tried the library but it didn't solve my problem. I'm still getting the "Unable to locate the file: layout.php" error.

I'm using "&lt;?php echo $template['body'];?&gt;" in my template as you can see from the description of my setup above. I also tried to replace "layout" with "index.php" in $this->template->build('layout', $data); but get the same error "Unable to locate the file: index.php"

[eluser]Phil Sturgeon[/eluser]
The newest version has changed to store layout files in:


Probably should have mentioned that to somebody at some point...

Hi Phil,

I don't know if your last reply referred to my post. Just in case I

1- went and created a "layouts" folder in "application/themes/default/views"
2- placed inside a copy of my "layout.php" and renamed it "default.php"
3- tried to run the code as it was and also modifying the controller "welcome.php" from "$this->template->build('layout', $data);" to "$this->template->build('default', $data);"

but I'm still getting the "Unable to locate the file: default.php (or template.php)"

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.