CodeCanyon

PHP Template Class

  • Australia
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
ItsBrad Purchased
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.

Default-user

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.

  • Bought between 50 and 99 items
  • Exclusive Author
  • Germany
  • Has been a member for 3-4 years
palle361 Purchased

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

  • Bought between 50 and 99 items
  • Exclusive Author
  • Germany
  • Has been a member for 3-4 years
palle361 Purchased

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’]; }

Default-user

Hi palle361,

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

  • Bought between 50 and 99 items
  • Exclusive Author
  • Germany
  • Has been a member for 3-4 years
palle361 Purchased

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

Default-user

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.

  • Bought between 50 and 99 items
  • Exclusive Author
  • Germany
  • Has been a member for 3-4 years
palle361 Purchased

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

  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 1-2 years
JhonnyL Purchased

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?

Default-user

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.

  • Australia
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
ItsBrad Purchased
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?

Default-user

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.

ItsBrad
ItsBrad Purchased

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

Default-user

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?

  • Bought between 10 and 49 items
  • Has been a member for 2-3 years

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

Default-user

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.

  • Australia
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
ItsBrad Purchased

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.

  • Bought between 100 and 499 items
  • Has been a member for 4-5 years

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.

Default-user

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.

Default-user

Hi ChrisFitz,

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

Thanks, cheers.

  • Australia
  • Bought between 1 and 9 items
  • Exclusive Author
  • Has been a member for 1-2 years
ItsBrad Purchased
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, '');
Default-user

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?

by
by
by
by
by