Hi,
I have been using K2 on a Joomla 1.5 site and now am upgrading to Joomla 3.x. When I needed to access the extra field values in one of the template pages I had a foreach loop that walked thru the extra fields until I found the one I needed and got its value. This worked from categories, items, and tag templates. Now with the new Joomla 3 version of K2 the categories and items templates have the same structure as they did in Joomla 1.5 and I can get the values that I need. But for some reason the tag structure is totally different for the extra fields.
For categories and items the extra fields structure looks like this:
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Street Address
[value] => 602-1888 York Avenue
[type] => textfield
[group] => 2
[published] => 1
[ordering] => 1
[alias] => StreetAddress
)
[1] => stdClass Object
(
[id] => 2
[name] => Price
[value] => 389000
[type] => textfield
[group] => 2
[published] => 1
[ordering] => 4
[alias] => Price
) ...
But on the tags page the structure looks like this:
[{"id":"1","value":"602-1888 York Avenue"},{"id":"2","value":"389000"},...
I need to get the 'Price' from the extra fields which is: 389000. So id 2's value. How to I code this so I can get out the value of id 2?
I tried:
[code
]foreach ($fields as $key=>$extraField):
if ($extraField->id == '2') {
$price = $extraField->value;
endforeach;
[/code]
But that isn't working, it gets an error:
Warning: Invalid argument supplied for foreach()
Any help would be appreciated.
Thank you.
I have been using K2 on a Joomla 1.5 site and now am upgrading to Joomla 3.x. When I needed to access the extra field values in one of the template pages I had a foreach loop that walked thru the extra fields until I found the one I needed and got its value. This worked from categories, items, and tag templates. Now with the new Joomla 3 version of K2 the categories and items templates have the same structure as they did in Joomla 1.5 and I can get the values that I need. But for some reason the tag structure is totally different for the extra fields.
For categories and items the extra fields structure looks like this:
Array
(
[0] => stdClass Object
(
[id] => 1
[name] => Street Address
[value] => 602-1888 York Avenue
[type] => textfield
[group] => 2
[published] => 1
[ordering] => 1
[alias] => StreetAddress
)
[1] => stdClass Object
(
[id] => 2
[name] => Price
[value] => 389000
[type] => textfield
[group] => 2
[published] => 1
[ordering] => 4
[alias] => Price
) ...
But on the tags page the structure looks like this:
[{"id":"1","value":"602-1888 York Avenue"},{"id":"2","value":"389000"},...
I need to get the 'Price' from the extra fields which is: 389000. So id 2's value. How to I code this so I can get out the value of id 2?
I tried:
[code
]foreach ($fields as $key=>$extraField):
if ($extraField->id == '2') {
$price = $extraField->value;
endforeach;
[/code]
But that isn't working, it gets an error:
Warning: Invalid argument supplied for foreach()
Any help would be appreciated.
Thank you.