Hello,
I'm still having some trouble with this...
the $u object is blessed, and the object is a hash reference.
The complete data structure I'm trying to access looks (in a simplified form) like
this:
$u = {
domains => {
domain.com => {
domain => 'domain.com',
status => 'active'
},
domain2.com => {
domain => 'domain2.com',
status => 'inactive'
}
}
}
In order to loop through the domains, I'm passing an array of the domains to the
template:
@domains = keys(%{$u->{domains}});
$vars->{"domains"} = \@domains;
and the object:
$vars->{"u"} = $u;
Then, this works fine (in the template):
[% FOREACH d = domains %]
<li>[% d %]</li>
[% END %]
What I really want to do, though, is print the status as well, and this does not work:
[% FOREACH d = domains %]
<li>[% d %]: status -- [% u.domains.d.status %]
[% END %]
I have also tried this instead, which doesn't work either:
[% u.domains.$d.status %]
The script doesn't die... it just doesn't print anything after status.
Is there something I'm doing wrong? Is there anything I should look for in the object
creation that might be causing this not to work?
Thanks for any info,
kristina
Andy Wardley wrote:
]
] On Wed, Jul 18, 2001 at 06:01:23PM +0200, Joerg, Harald wrote:
] > If $u is a perl object (a "blessed" thing), then the toolkit translates
] > user.username into the method call $u->username().
]
] ....and if that method isn't found, then it should attempt to access
] it as $u->{'user'} (assuming the underlying object is a hash ref).
]
] So it should work as expected, but there might be something in the
] object which is preventing this from happening (e.g. an existing
] 'username' method or an AUTOLOAD method, perhaps).
]
] Here's an example showing how it should work:
]
] [abw@gemini abw]$ perl -MTemplate \
] -e 'Template->new(EVAL_PERL => 1)->process(\*STDIN)'
] [% PERL %]
] $stash->set( me => bless { name => 'abw' }, 'user' );
] [% END %]
] me: [% me.name %]
] ^D
]
] and it generates:
]
] me: abw
]
]
] HTH
] A
]
] --
] Andy Wardley <[EMAIL PROTECTED]> Signature regenerating. Please remain seated.
] <[EMAIL PROTECTED]> For a good time: http://www.kfs.org/~abw/
]