Re: Variables in variables
| From: | Marc Debold | Date: | Mon, 04 Nov 2002 15:42:50 +0000 |
| Subject: | Re: Variables in variables | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-6322@lists.php.net to get a copy of this message | ||
Hello again,
seems like I have to be a little more specific with my problem. Ok, in
detail I have the following:
I have a class named "shop" that should provide a frontend for some sort of
online-shop. For this shop, I load all of the data in the class definition
from a mysql db. I want to provide the ability, that the shop-owner can
customize his starting page, using the variables provided by my shop-class.
The problem is, that the layout for the starting page is already assigned by
my include file like this ...
... header.php ...
[...]
$smarty->assign($shop->data);
[...]
... whereby $shop->data is an associative array that contains all my
shop-data :). In $shop->data I have $shop->data["Shop_Name"] and
$shop->data["Shop_FrontPage"]. Now the example, how I would think smarty
should work, but doesnt.
... index.php ...
[...]
require "head.php";
$smarty->display("index.tpl");
[...]
... index.tpl ...
<html>
<head>
<title>Online Shop {$Shop_Name}</title>
</head>
<body>
{$Shop_FrontPage}
</body>
</html>
So if my data would be the following (pseudo code):
Shop_Name = Test Shop
Shop_FrontPage = Welcome to {$Shop_Name},<br> nice to meet you.
I would expect that the {$Shop_Name} variable would be replaced by Test
Shop, but instead it is left blank. The title is displayed correctly, so
there is no problem with the variables.
See my problem? I already got everything assigned in smarty, but it doesn't
work like I want it to.
Any ideas welcome.
Marc
"Marc Debold" <Marc.Debold@tec-systems.de> schrieb im Newsbeitrag
news:20021031155018.35254.qmail@pb1.pair.com...
> Hello there,
>
> I'm trying to have some vars within another var, but don't know how to
do
> it. I want to make a customizable welcome-page, that can contain e.g. the
> name of the user inserted via smarty varaible. Example:
>
> php:
> <?php
> $name = "Santa";
> $greet = "Hello {$name}, nice to meet you again";
> ...
> ?>
>
> template:
> <html>
> ...
> {$greet}
> ...
> <html>
>
> output:
> <html>
> ...
> Hello Santa, nice to meet you again
> ...
> </html>
>
> Is that possible without using several template files? I have n customers,
> that have m customers, and each wants another welcome page.
>
> Best regards,
>
> Marc
>
>