Results 1 to 12 of 12

Thread: SMARTY troubles

  1. #1

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    SMARTY troubles

    i am using smarty to template a site. this is my first time using smarty and well, the following code is not working although its exactly the same in the guides.

    Code:
    require('lib/Smarty.class.php');
    $smarty = new Smarty();
    
    $smarty->assign('lol', 'lmao');
    $smarty->display('template.tpl');
    it displays nothing. absolutely nothing.
    however if i add code to echo something after this code it echoes? doesn't that mean there is no error or whatsoever?

  2. #2
    Lively Member
    Join Date
    Feb 2008
    Location
    Denmark
    Posts
    113

    Re: SMARTY troubles

    have you made a map called lib where smarty is?

    Dosent you have to assign a map where the template are?
    PHP: ClassDB

    VB6:
    Own code: Google Translater

    Over and out from Snortop!!

  3. #3

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: SMARTY troubles

    i am sorry but... what?

    i do have a folder called lib and Smarty.class.php is there.
    and the template.tpl file is in the same folder as index.php so i thought there was no need to set up the templates path variable. i also tried by putting the tpl file in the same folder as smarty.class.php but the result is same.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: SMARTY troubles

    Ensure that error reporting is set to E_ALL, you can do this by changing the php.ini or adding the following line of code to the top of the script:
    Code:
    error_reporting(E_ALL);
    Give us details of any error if you cannot find the solution.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: SMARTY troubles

    again i am surprised.
    no errrors or whatsoever. the page still stays blank. o_O

    here is the full code of my page.

    Code:
    <?php
    
    error_reporting(E_ALL);
    
    include("myclass.php");
    include("config.php");
    $myClass = new myClass();
    $myClass->INFO = $CONFIG;
    $myClass->init();
    
    
    require('lib/Smarty.class.php');
    $smarty = new Smarty();
    
    $smarty->assign('lol', 'lmao');
    $smarty->display('template.tpl');
    
    
    //$myClass->returnSomething();
    ?>

  6. #6
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: SMARTY troubles

    can you post the content on your template.tpl page?
    My usual boring signature: Something

  7. #7
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: SMARTY troubles

    In addition you can set the error reporting level in Smarty using the error_reporting property.
    Code:
    $smarty->error_reporting = E_ALL;
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  8. #8

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: SMARTY troubles

    @dclamp :

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    background:#000000;
    }
    
    .date {
    color:#00FF00;
    }
    .post {
    color:#00FF00;
    }
    </style>
    </head>
    <body>
    {$lol}
    </body>
    </html>
    @visualAd:
    still blank

    i am using apache2triad 1.5.4. i checked the php dir of the bundle and smarty apparently comes with apache2triad.

    however the smarty i am have put in the require() function is one i downloaded from smarty.net and it is inside a folder called lib which is the same folder as index.php

    i found the problem with error reporting. error display had to be turned on.

    the error i get now is :
    Fatal error: Smarty error: [in template.tpl line 7]: syntax error: unrecognized tag: background:#000000; (Smarty_Compiler.class.php, line 446) in C:\apache2triad\htdocs\snog\lib\Smarty.class.php on line 1092

    that that might be important in some way ^_^
    Last edited by Beasts; Sep 20th, 2008 at 10:20 PM.

  9. #9
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: SMARTY troubles

    Quote Originally Posted by Beasts
    @dclamp :

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
    background:#000000;
    }
    
    .date {
    color:#00FF00;
    }
    .post {
    color:#00FF00;
    }
    </style>
    </head>
    <body>
    {$lol}
    </body>
    </html>
    I downloaded smarty (and i think it is AWESOME), but i had CSS on my page, and it gave me an error. Since css uses the same Braces that Smarty uses, it could be causing the error you are having.

    Css should be in a separate file for cleanliness and effectiveness
    My usual boring signature: Something

  10. #10
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: SMARTY troubles

    I think dclamp's right.

  11. #11
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: SMARTY troubles

    You can change the open an close characters in Smarty to something other than {}; however, it is good practice not to put JS or CSS in the page and this avoids it all together.

    You can also use {ldelim} and {rdelim} to print the literal delimiters without Smarty misinterpreting them or the {literal} instructions to disable entire blocks.

    http://www.smarty.net/manual/en/lang...ion.ldelim.php
    http://www.smarty.net/manual/en/lang...on.literal.php
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  12. #12

    Thread Starter
    Addicted Member Beasts's Avatar
    Join Date
    Oct 2006
    Posts
    147

    Re: SMARTY troubles

    i think i will attach the stylesheet.

    I have deleted all the CSS but it still gives the same error? Cache or something?
    i have tried changing the filename. but gives this error. but the file exists.

    Warning: Smarty error: unable to read resource: "templatess.tpl" in C:\apache2triad\htdocs\snog\lib\Smarty.class.php on line 1092

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width