|
-
Sep 19th, 2008, 06:33 PM
#1
Thread Starter
Addicted Member
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?
-
Sep 20th, 2008, 03:10 AM
#2
Lively Member
Re: SMARTY troubles
have you made a map called lib where smarty is?
Dosent you have to assign a map where the template are?
-
Sep 20th, 2008, 03:20 AM
#3
Thread Starter
Addicted Member
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.
-
Sep 20th, 2008, 05:37 AM
#4
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.
-
Sep 20th, 2008, 07:36 AM
#5
Thread Starter
Addicted Member
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();
?>
-
Sep 20th, 2008, 11:29 AM
#6
Re: SMARTY troubles
can you post the content on your template.tpl page?
My usual boring signature: Something
-
Sep 20th, 2008, 12:28 PM
#7
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;
-
Sep 20th, 2008, 09:53 PM
#8
Thread Starter
Addicted Member
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.
-
Sep 21st, 2008, 12:47 AM
#9
Re: SMARTY troubles
 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
-
Sep 21st, 2008, 02:20 AM
#10
-
Sep 21st, 2008, 02:30 AM
#11
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
-
Sep 21st, 2008, 06:08 PM
#12
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|