Nested objects as arguments

From: Date: Tue, 12 Nov 2002 03:04:37 +0000
Subject: Nested objects as arguments
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-6399@lists.php.net to get a copy of this message
Hello, I've been very happily using Smarty for a while now. Just recently, I've been reorganizing some of the things I use more often into include files. I'm finding that nested objects don't seem to work as include parameters. To be more specific: Suppose I have an object for each membership called 'member'. For each member, I have contact information (name and address), which is stored as an object called 'contact' which is a property on member. So, in PHP, I would get a first name with: $member->contact->FirstName; When using Smarty, I've been quite successful writing templates of the form: {$member->contact->FirstName} In the case above, I get the first name as expected. Now I want to do: {include file="nameAddress.tpl" firstName="$member->contact->FirstName"} When I use {$firstName} inside nameAddress.tpl, I get: Object->BusinessName which isn't what I was expecting. I've tried making an end run around the problem by assigning $member->contact or even $member->contact->FirstName to a variable using the assign function, but that doesn't seem to solve my problem. In the former case, the variable just seems to be blank (empty string), and in the latter case I get the same 'Object->BusinessName' output. I've read the documentation for information, and while it addresses the topic of nested array references, nested object references are not explicitly mentioned. How can I make passing string properties nested inside composed objects work when passed as arguments to an include? Thank you, Jeffrey jhoward@burningvoid.com

« previous php.smarty.general (#6399) next »