|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
jkramer@billitco.com Smarty n00b
Joined: 06 Feb 2015 Posts: 1
|
Posted: Fri Feb 06, 2015 7:43 pm Post subject: Assigning value of $array.$index->get_method() to variabl |
|
|
In my TPL file I have an loop like so:
{foreach from=$vehicles item=vehicle}
{assign var="vehicle_id" value=$vehicle->get_vehicle_id()}
{assign var="lease" value=$leases_by_ids.$vehicle_id}
{assign var="leasedate" value=$lease->get_date()}
{/foreach}
*Note:
$vehicles is an array of objects
$leases_by_ids is a array of objects
When executed I get "...called on a non-object".. ideas? Syntax?
Please and thank you. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Sat Feb 07, 2015 11:48 am Post subject: |
|
|
The error message did tell you the failing method. Then you know the variable which is not an object as expected.
Best guess is that the value of $vehicle_id points to a none existing element of array $leases_by_ids.
The following would be also valid code:
Code: | {assign var="leasedate" value=$leases_by_ids[$vehicle_id]->get_date()}
or
{assign var="leasedate" value=$leases_by_ids[$vehicle->get_vehicle_id()]->get_date()} |
|
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|