Jump to content

Smarty Help


xyn
 Share

Recommended Posts

Hey Guys,

 

Those of you who are formiliar with Smarty Templates (http://smarty.php.net)

Could you please help me, because I'm slightly stuck...

 

Basically i create my object and arrange everything correctly, and nothing happens

 

Page_Test.php

<?php
include("Plug.class.php"); // This is one hing i haven't got...

$plug = new Smarty; //Object created

$plug->assign('U_NAME', 'Paul');
$plug->assign('AGE', '25');

//Display it
$plug->display("form.tpl");
?>

 

 

form.tpl

<html>
<head>
<title>User Info</title>
</head>
<body>

User Information:<p>

Name: {U_NAME}<br>
Age: {AGE}<br>

</body>
</html>

 

I'm confused.

Link to comment
Share on other sites

I might be barking up the wrong tree here but here it goes, When i used smarty last i had to replace the <?php ?> tags with {php} {/php}

 

That's only if you're including actual PHP script within the template itself. In the case of xyn, though, he's using an external tpl file, so he shouldn't have to worry with that step.

 

@xyn - The "one thing you haven't got" seems to be your problem. You must be including the Smarty class on your page somewhere to be able to use it. Unless your Plug page you're including is actually extending the Smarty class itself, you're stuck. You have to include the Smarty class definition file, and then you can create the new Smarty object.

Link to comment
Share on other sites

@xyn - The "one thing you haven't got" seems to be your problem. You must be including the Smarty class on your page somewhere to be able to use it. Unless your Plug page you're including is actually extending the Smarty class itself, you're stuck. You have to include the Smarty class definition file, and then you can create the new Smarty object.

 

Any ideas what this "Class definition file" is / looks like? Orhow i can create it :S

(I'm very new to this Smarty Engine)

Link to comment
Share on other sites

Any ideas what this "Class definition file" is / looks like? Orhow i can create it :S

(I'm very new to this Smarty Engine)

 

Umm... that's actually the core of Smarty. That's what you have to download and install. Have you gone through the tutorials or the crash course on the smarty website? That takes you through installation and setup of your first Smarty script... might be very useful at this point.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.