ChrisFitz

ChrisFitz does not currently provide support for this item.

38 comments found.

Hey, I brought this and it works good but I tried creating a login form like: if(isset($_POST['submit'])) { }
but if I did a varible for a error if($username == '') { $error .= "Error"; }
Then i echoed it out in the html file like <?php echo $error; ?>
it didn’t work, so i tried adding it to the array part, then used: {ERROR} but then no text would be showing….

Please help.

Hi ItsBrad,

Try “echo $error;exit;”. The template script uses exit at the end because it buffers the output, so any echo should be appended with an exit before the template is rendered (before the display() function is called.

Let me know if you need anything else.

hi thx for this nice file. you can make an example how to get left with the class used for? index.php? load = news, etc.? best greetings

I would like to invite always another content. Can you help me?

$section = array(); $section[‘news’] = ‘plugins/example/list.php’; $section[‘gb’] = ‘plugins/example2/list.php’;

if (isset($_GET[‘section’], $section[$_GET[‘section’]])) { include $section[$_GET[‘section’]]; } else { include $section[‘news’]; }

Hi palle361,

Can you be more specific on what you’re trying to accomplish?

I want to create a dynamic content Index.php. which is a placeholder in the Index.html outputs the contents of plugins / example / list.php or is invoked when another call plugins/example2/List.php. Include () dosnt work. I hope you now understand what I mean. Greeting

If the pages you’re trying to include are outputting data, either by echo or html code it will not work. In order to be able to do so you’d have to convert the plugins, etc to use the template system as well.

I hope this was what you were asking for, but let me know if you were looking for something else.

When i change the line: if ($result = $database->query($sql, 3600)) { to if ($result = $database->query($sql)) { works then it works but that is not the intention. big thanks and greetings

I have set a value to 0 as default in the database. It’s a rating so unless someone has rated it should show 0. I guess this line ”<?php echo !empty(\$this?>data’.’[’\\1’]) ? \$this->data’.’[’\\1’] : ’’; ?>”, removes that 0 and replaces it with an empty string. Is there any solution to this?

Hi JhonnyL,

You are indeed correct. Thank you for pointing that out, I’ll update it as soon as I can. For now what you can do is change the “empty” with “isset” and that should resolve the issue.

Hey me again, I am creating a login, and this is what I got: if (isset($_COOKIE['username'])) { // Set the template vars $template->vars(array( 'VAR_1' => $var, 'VAR_2' => 'Hello World!', 'USERNAME' => $_COOKIE['username'], )); $template->display('Index of BM', 'login_main.html', './template/style.css', 'js-file.js'); // Index for user } else { if(isset($_POST['submit'])) { $template->display('Index of BM', 'login_main.html'); // Index for guest } else { $template->display('Index of BM', 'login_main.html'); // Index for guest } }

But if the user has errors how can I show them?

Hey ItsBrad,

I’m assuming by errors you mean ones that would arise when they “submit” the form (inside the if statement that’s checking for the $_POST['submit']). If that’s the case you could do something like

if (isset($_POST['submit'])) {
    // login logic would go here
    if ($success) {
        $title = 'Success!';
        $template = 'success.html';
        $template->vars(array(
            'SUCCESS' => 'It worked!'
        ));
    } else {
        $title = 'Failed!';
        $template = 'failed.html';
        $template->vars(array(
            'FAILED' => 'It didn't work!'
        ));
    }
    $template->display($title, $template);
}

I’m not sure if this is what you’re looking for, but that’s one way to show errors depending on the result of the form POST . If you’re looking for something else, just let me know and I’ll try to find a method that will work for you.

Hey man, sorry for a really late resonponse it’s not working

Hi ItsBrad,

Can you give me a little more details about what it did do so I can try to help you narrow why it didn’t do what it was supposed to do?

You can capture templates from a mysql database. I have all html files in a database, and need to load the templates from mysql. Is it possible? thanks

Hi novoo,

Unfortunately the way the class was written pulling the template data from a database would be impossible without rewriting the function that retrieves the template.

Hey, I have two classess, one work’s but the other’s not?

Index.php

<?php session_start(); // Initializes the template class include ("./global.php"); // Basic var example $header->header_main(); $main->index_main(); ?>

$main->index_main(); isn’t working, seems only one class can work.

Hi ChrisFitz,

I tried compress via yuicompress, but it doesn’t work. file is created but it is not compressed. Compress function returns false. What could be the problem?

Thanks, cheers.

Hi murselturk,

If the file is create, but isn’t compressed when the compression option is enabled it most likely means that either exec() isn’t able to execute .jar file or java isn’t available on the server. I would check if either of those things are available on your web host, and if they are please double check to make sure the yuicompress file (the .jar file) is in the correct location that is set in the configuration.

Hi ChrisFitz,

I sent mail from your profile page. My ftp details are in that mail.

Thanks, cheers.

Hey, some reason, im trying to get stuff from db to load on a page, it’s not working.
    $query = mysql_query("SELECT * FROM status");

    if(!$query) {
        $template->vars(array(
            'MYSQL_ERROR' => mysql_error()
        ));
    }

    while($row = mysql_fetch_array($query)) {
        $template->loop('mysql', array(
            'AUTHOR' => $row['authorpost']
        ));
    }
    $template->display('Zamiy | Welcome', 'index_main.html', '', null, '');

Hi ItsaBrad,

Is there any error that appears, or does it just show up blank? If it shows up blank, can you try to echo $row[‘authorpost’] to the page and see if that works?

Hey Chris, I have made a software, I plan to sell it at a price, but im using your Template Engine, just making sure that I can sell it or not.

Hi ItsBrad,

As long as you leave my information (and credit) in the files, you have my permission.

Hello Chris! I like your Template engine very much, its fast and handy :-)! Now that I went into some deeper using, I have 3 things to ask and recommend:

1.) Theres no option to switch cache OFF, just for development, if I need to see if its really the current output, when I made changes, and not the cache view.

2.) In this context: When I delete the generated cache php file, as a workaround for what mentioned above – ok. BUT If I had included some other htnl files, they are also in cache folder with ending php, and when I delete them- big “missing stream” error comes up. Is that a bug?

3.) And last a recommandation for a feature that should be that hard to plug in:

It would be great if the Class erases all other development comments in the html when parsing, Because its just already scanning for comments, so why not wipe out all unnecessary?

Thanks for answering!

Thank you Chris!

For Nr. 1 – I modified the check_expiration function to always returning in any case false.

Not the cleanest solution- but , just for development.

OK, or do you expect any issues with that?

That should do it. Ideally, you’d have a configuration variable that can be set on initialization to toggle it on or off, but in the end it would do that same thing as what you did.

Thank you! Again : I love your work !

Question: My script goes over several pages, with users, having theis data in sessions.

To parse the html I have to create the object ´template´everytime with —>new. But so the ´data´-array will be set to empty any time.

Is there a way just to add something to existing ´data´? So I could keep users variables over several sites?

Waht i do now, is to keep everything in a session, and on every site I put the users variables, stored in the session, into the object with ´vars´.

So if I try to implement some translation-feature, I have to reload all text-snippets with the function vars again, on every site.

So any way to add something and keep the previous data, ?

Thank you!

Well, just I got a serious issue:

I got php warning:

Warning: ob_start() [ref.outcontrol]: output handler ‘ob_gzhandler’ cannot be used after ‘URL-Rewriter’ in /.../template.php on line 280

what may that be?? :-(

Hi kiroman,

I believe this error is caused by a conflicting setting from your Apache setup. If your server already has gzip or deflate enabled, you can set the gzip option in this class to false and this problem should be resolved.

I´ll check this – thanks :-)

if my server doesn’t support

Ability to execute .jar files via PHP ’s exec() function is required for compressing css and javascript files.

can i use anything?

thank you

Hello

Is really simple, congratulations.

Is there a way to NOT use a template file?, only code.

I want to replace data in a PHP script. That’s all I need it. Is possible with PHP Template Class?.

thanks.

JR

Hi! Will the caching work even if I have more than one “user” on my site, with different content injected to the template?

Is it possible to switch caching off (for develepment e.g.)?

Is the reading of a cached precompiled file from server really faster than compiling it again? Thank you!

supported this also browsercaching

by
by
by
by
by
by