0

Here is my code, from the search results page:

{if $listing.SalaryType!=''&& $listing.Salary!=''}<dt>Salary:</dt>
<dd>{$listing.Salary} {$listing.SalaryType}</dd>{/if}

Which gives this output:

Screenshot

It says 'Array' instead of the correct value. Any idea where I can start looking to solve this problem? Where is the 'Array' coming from?

Here is some more information. On the job details page, this code:

<div class="smallListingInfo"><strong>[[FormFieldCaptions!Salary]]:</strong> {display property=Salary} [[$listing.SalaryType]]</div>

Gives this output:

second example

You can see the salary value works in this instance, how is that different?

Using the smarty debug console I got the following:

Title => Services Senior Manager
EmploymentType => Contractor
JobCategory => Accounting,Admin-Clerical
Occupations => empty
Country => United States
Salary => Array (5)
  add_parameter => 2
  value => 30000
  currency_sign => £
  course => 1
  currency_code => USD
State => California
SalaryType => per month
City => Los Angeles

How do I get the value to show instead of 'Array'?

0

3 Answers 3

1

$listing.Salary seems to be an Array.

Insert {debug} in your HTML code for dumping the debug console wich shows you the assigned variables.

Search for "debug" in the Smarty documentation (sorry, i can't post links here right now)

How to access elements of arrays in Smarty can also be found in the docs, just search for "variables"

Sign up to request clarification or add additional context in comments.

2 Comments

{if $listing.SalaryType!=''&& $listing.Salary!=''}<dt>Salary:</dt> <dd>{$listing.Salary.value} {$listing.SalaryType}</dd>{/if}
optional you may use {$listing.Salary.currency_sign}
1

It means the {$listing.Salary} value is an array instead of the value you expect. When PHP is asked to treat an array as a string, it'll use the value "Array". Fix your data structures and/or your template to use the right value.

$foo = array();
echo $foo; // echoes "Array"

Comments

0

{$listing.Salary} is an array.

In the PHP code, the object/array you pass to the template : 'Salary' index or attribute should return an integer and not an array.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.