CodeIgniter Forums
Need some help with my libraries - 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: Need some help with my libraries (/showthread.php?tid=4547)

Pages: 1 2


Need some help with my libraries - El Forum - 12-01-2007

[eluser]Techie-Micheal[/eluser]
I could use some help, per the subject. Being new to CI, I would appreciate some help testing my two new libraries and making sure I did things the "CI way."

Right now all I've done is rip out phpBB3's templating engine and modify it a bit for CI for general use without needing phpBB installed. I plan to do the same with phpBB3's DBAL, sessions, and ACL. As well as write a helper or two to tie it all in and tie a phpBB install to your app.

At any rate, here's the tarball of the two files: http://www.michealcottingham.com/ci_phpbb3_template.tar.gz

I know there are some things that need to be fixed and cleaned up (right now it is rather messy), but at least it seems to work. Here's the code I put in my controller, using autoload.php to setup the templating.

Code:
$this->phpbb3_template->set_custom_template('./templates', 'home');
        $this->phpbb3_template->set_filenames(array(
            'body' => 'blah_body.html'
        ));
        $this->phpbb3_template->display('body');

Create a templates directory in the root of your app and create a cache folder in your application folder.

For example:

index.php - front controller
system/ - the system folder
application/ - the controllers et al
templates/ - where you'll store the template files, css, whatever else

Or:

../system/ - the system folder
../application/ - the controllers et al
index.php - front controller
templates/ - where you'll store the template files, css, whatever else

You get the idea. So, feedback please!


Need some help with my libraries - El Forum - 12-02-2007

[eluser]BoltClock[/eluser]
OK, I got it up and running as you instructed without error. The problem is, though the library is able to detect my template file, nothing is being output.

Here's my file layout:

index.php
system/
- application/
- - cache/
- other folders
templates/
- test.html

Here's my testing controller:

Code:
<?php

class Test extends Controller
{
    public function index()
    {
        $this->phpbb3_template->set_custom_template('./templates', 'home');
        $this->phpbb3_template->set_filenames(array(
            'test' => 'test.html'
        ));
        $this->phpbb3_template->assign_vars(array(
            'TITLE' => 'Testing title',
            'TESTVAR' => 'Hello world!'
        ));
        $this->phpbb3_template->display('test');
    }
}

?>

Here's my template file (test.html):

Code:
<html>
  <head>
    <title>{TITLE}</title>
  </head>
  <body>
    <p>{TESTVAR}</p>
  &lt;/body&gt;
&lt;/html&gt;

I've never used phpBB3's template system before so it may be a problem on my part.

<b>EDIT:</b> While CI was able to find the library, I believe the user guide says to capitalize the class name, so <strong>Phpbb3_template</strong> (though there's no need for phpbb3_template_compile since it's loaded internally by the former).

[quote author="Techie-Micheal" date="1196585463"]I plan to do the same with phpBB3’s DBAL, sessions, and ACL. As well as write a helper or two to tie it all in and tie a phpBB install to your app.[/quote]

That sounds awesome, I can't wait till it's ready! Though in the meantime I may have to put up with other means because I want to get my site up within a month :/

<b>EDIT 2:</b> I forgot to make a cache folder, so I did, but it still isn't working.


Need some help with my libraries - El Forum - 12-02-2007

[eluser]BoltClock[/eluser]
... double post.


Need some help with my libraries - El Forum - 12-02-2007

[eluser]Techie-Micheal[/eluser]
Edit: On second thought, try this, just to see:

Code:
$this->phpbb3_template->set_filenames(array(
            'body' => 'test.html'
        ));

And of course changing test to body in the display call. Otherwise, you are correct.


Need some help with my libraries - El Forum - 12-02-2007

[eluser]Techie-Micheal[/eluser]
It shouldn't make any difference, and it didn't for me.

Did you make sure cache was writable? I forgot to add that in to the above. Other than that, I can't think of anything. It is working just fine for me. Oh, PHP5, right? It shouldn't matter, but just checking.


Need some help with my libraries - El Forum - 12-02-2007

[eluser]BoltClock[/eluser]
Nope, still not working.

It <b>seems</b> like include() could be the problem. I don't think CodeIgniter will be happy include()ing directly into the controller. Just to hunt around for the problem I added die() to phpbb3_template::display() just after the include() command and sure enough it dies right there, with the output being shown. It could have something to do with include(). I'm not entirely certain though.

<b>EDIT:</b> Didn't see your reply. Anyway, cache is definitely writable because the compiled template file appears there. Yes, PHP 5.


Need some help with my libraries - El Forum - 12-03-2007

[eluser]Techie-Micheal[/eluser]
Odd. I wonder why it works fine for me. And actually, I found a bug in the compiling, but it doesn't affect display for me. It just recompiles the template every page load, which is a no-no. Tongue But I don't know why CI would get upset with the include for you when it doesn't for me. Obviously since I can't reproduce it I'm going to have a harder time fixing it. Tongue If anybody else has an suggestions as to why this may not work if it it does/doesn't work for them, I'm all ears.


Need some help with my libraries - El Forum - 12-13-2007

[eluser]darkera13[/eluser]
Open file : phpbb3_template_compile.php

FIND :
Code:
global $phpEx;

        $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.' . $phpEx;

REPLACE WITH :
Code:
$filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.php';



Need some help with my libraries - El Forum - 12-14-2007

[eluser]BoltClock[/eluser]
I found the problem: it was with the server's compression :|


Need some help with my libraries - El Forum - 12-16-2007

[eluser]Techie-Micheal[/eluser]
[quote author="darkera13" date="1197629537"]Open file : phpbb3_template_compile.php

FIND :
Code:
global $phpEx;

        $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.' . $phpEx;

REPLACE WITH :
Code:
$filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . '.php';
[/quote] Thanks, I missed that one.

Quote:I found the problem: it was with the server’s compression :|
How so?

I'm going to go ahead and start working on pulling out the phpBB3 DBAL so that sessions and such will work when I do those. Tongue

I still have the compile problem, but it isn't showstopping, so I'll continue. Just trying to get a rough set of libraries, then I'll clean them up.