Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Whats the problem with this smarty code?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
vary88
Smarty n00b


Joined: 17 Nov 2011
Posts: 3

PostPosted: Thu Nov 17, 2011 4:47 pm    Post subject: Whats the problem with this smarty code? Reply with quote

include_once("../smarty/libs/Smarty.class.php");
$smarty = new smarty();
$smarty->setTemplateDir('templates/');
$smarty->setCompileDir('templates/z_complied');
$smarty->setCacheDir('templates/z_cached');

$a = "something";
$smarty->assign('sy', $a);


--- and then in the html:

<div>
{$sy}
</div>

------
the output is "$sy" and not the "something". Why?
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Nov 17, 2011 5:18 pm    Post subject: Reply with quote

what is the rest of the code? do you have

$smarty->display('index.tpl');

And that is the source of the index.tpl file? is the output just $sy, or <div>{$sy}</div> literally, or something else? (view source of browser if looking at it in a browser)
Back to top
View user's profile Send private message Visit poster's website
vary88
Smarty n00b


Joined: 17 Nov 2011
Posts: 3

PostPosted: Thu Nov 17, 2011 7:09 pm    Post subject: this is my code Reply with quote

----index.php:

<?
include_once("../smarty/libs/Smarty.class.php");
$smarty = new smarty();
$smarty->setTemplateDir('templates/');
$smarty->setCompileDir('templates/z_complied');
$smarty->setCacheDir('templates/z_cached');

$a = "szoveg";
$smarty->assign('het', 'eztfogja odaadni');

include_once("head.tpl");
include_once("page.tpl");

---------page.tpl (head.tpl is not interest:
<body onload="load()">
<div id="idcont" class="container">
<div class="menu">
menü
</div>

<div class="content">
<div id="idhead" class="head">
<div class="little">
<div class="but"><button> <- </button></div>
<div id="ide" class="ide">
{$het}
</div>
<div class="but"><button> -> </button></div>
</div>
</div>
<div class="tables">
<table>
<tr class="tableshead">
<td>Hétfő</td>
<td>Kedd</td>
<td>Szerda</td>
<td>Csütörtök</td>
<td>Péntek</td>
<td>Szombat</td>
<td>Vasárnap</td>
</tr>
<tr class="tablescontent">
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
<td>7</td>
</tr>
</table>
</div>
</div>

</div>
</body>
</html>
Back to top
View user's profile Send private message
mohrt
Administrator


Joined: 16 Apr 2003
Posts: 7368
Location: Lincoln Nebraska, USA

PostPosted: Thu Nov 17, 2011 7:16 pm    Post subject: Reply with quote

I see a problem:

Code:
include_once("head.tpl");
include_once("page.tpl");


That just includes the file like a PHP script. You need to use $smarty->display().
Back to top
View user's profile Send private message Visit poster's website
vary88
Smarty n00b


Joined: 17 Nov 2011
Posts: 3

PostPosted: Thu Nov 17, 2011 7:40 pm    Post subject: :) Reply with quote

ohhh thanky you, yeah it was my bad !!!!!!! Sure, sorry for the donkey quest Very Happy Very thank you
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP