By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,088 Members | 975 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,088 IT Pros & Developers. It's quick & easy.

PHP & TPL files

P: n/a
a simple questions.

how can I echo a variable made on in a PHP file inside a tpl file.
the TPL file is included inside the PHP file.

any suggestions?

Oct 30 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Maximus wrote:
a simple questions.

how can I echo a variable made on in a PHP file inside a tpl file.
the TPL file is included inside the PHP file.

any suggestions?


Are you using a template parser ?
If so, look in the documentation of the parser.

If not, include the template only after you have created your variables
and by having {$variablename} in the tpl file where you want the
variable to be placed it will automatically be replaced.

Even so, it all really depends on your set up, i.e. how the tpl file is
used and interpreted, so the suggested solution may not work.
If it doesn't give us some code so we can make educated suggestions.
Oct 30 '05 #2

P: n/a
Thanks Juliette. It worked.

If there's any link can give me that provides info about TPL files i'd
be thankful.

Oct 30 '05 #3

P: n/a
Maximus wrote:
Thanks Juliette. It worked.

If there's any link can give me that provides info about TPL files i'd
be thankful.


Hi Maximus,

If my suggestion worked, you don't need to read up on template files,
you need to read up on the include statement and understand how that
works: http://www.php.net/manual/nl/function.include.php

If you really want to works with proper templating, you may want to look
at some open source template parsers.
There are numerous ones available, I won't recommend any as which one
would be best, depends on your requirements.

Grz, J.
Oct 30 '05 #4

P: n/a
I really recomend the PHP templating parser. I've heard it is really
powerful. And from what I can tell in my experience, it is really easy
to use.

Oct 30 '05 #5

P: n/a
What is a template parser? I use Savant currently.

Tezza wrote:
I really recomend the PHP templating parser. I've heard it is really
powerful. And from what I can tell in my experience, it is really easy
to use.

Oct 31 '05 #6

P: n/a
In this context, I suppose you could describe a template parser as a
program which "processes" or "interpertes" template files.

An example of a template is

<?php include "BusinessLogic.php"; ?>
<html><head><title><?php echo $title ?></title></head>
<body>
<h1><?php echo $title ?></h1>
<?php echo $content ?>
</body>
</html>

and php is the program that can interperate this template. Note, your
graphic designer can also load this template up in a product like
dreamweaver and work with the design.

Neat huh?

Oct 31 '05 #7

P: n/a
I had a quick look at servant.
http://www.phpsavant.com/yawiki/inde...e=StartExample
It actually does use PHP for it's templates - which is good.
I would say it is more of an application framework for controlling
separation of concerns (SOC) and things like error management etc. So I
quite like it. It's better than nothing, and will save you making your
own application framework.

However, I wouldn't use it myself.

Oct 31 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.