- Posts: 46
COMMUNITY FORUM
How to fetch specific extra field selected val
- ATHANASIOS ILIOPOULOS
- Topic Author
- Offline
- Senior Member
Less
More
8 years 2 weeks ago #159068
by ATHANASIOS ILIOPOULOS
How to fetch specific extra field selected val was created by ATHANASIOS ILIOPOULOS
I am trying to make some customizations in my:
administrator\components\com_k2\views\item\tmpl\default.php
file and to print somewhere item's extra field selected values.
In file's code i can see that i can get extra field name and element like:
however "$extraField->value" does not seem to work. It
I have also tried to access item's extra field values by using:
But "$item->extra_fields" does not seem to work at administrator item.php template of K2.
Any suggestions?
administrator\components\com_k2\views\item\tmpl\default.php
file and to print somewhere item's extra field selected values.
In file's code i can see that i can get extra field name and element like:
<?php if (count($this->extraFields)): ?>
<?php foreach($this->extraFields as $extraField): ?>
<?php echo $extraField->name; ?>
<?php echo $extraField->element; ?>
<?php endforeach; ?>
<?php endif; ?>
however "$extraField->value" does not seem to work. It
I have also tried to access item's extra field values by using:
$extrafields = array();
foreach($item->extra_fields as $item)
{
$extrafields[$item->id] = $item->value;
}
But "$item->extra_fields" does not seem to work at administrator item.php template of K2.
Any suggestions?
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 week ago #159123
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic How to fetch specific extra field selected val
Hello there,
The syntax in the administrator template is a bit different.is being used.
Depending on the PHP version some str_replace might be needed in order to use json_decode.
Use this snippet as a starting point.
The syntax in the administrator template is a bit different.
$this->row->extra_fields;
Depending on the PHP version some str_replace might be needed in order to use json_decode.
Use this snippet as a starting point.
<?php if($this->row->id): ?>
<?php $extra_fields = str_replace('"', '"', $this->row->extra_fields); ?>
<?php var_dump(json_decode($extra_fields)); ?>
<?php endif; ?>
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- ATHANASIOS ILIOPOULOS
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 46
8 years 1 week ago #159137
by ATHANASIOS ILIOPOULOS
Replied by ATHANASIOS ILIOPOULOS on topic How to fetch specific extra field selected val
Hi Krikor,
thanks for your response, it helped! Resolved it like:
and then accessing each extra field value like:
thanks!
thanks for your response, it helped! Resolved it like:
<?php if($this->row->id): ?>
<?php $extra_fields = str_replace('"', '"', $this->row->extra_fields); ?>
<?php $extrafields1 = json_decode($extra_fields) ?>
<?php $sample_type = $extrafields1[5]; ?>
<?php endif; ?>
and then accessing each extra field value like:
$sample_type->value
thanks!
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
8 years 1 week ago #159138
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic How to fetch specific extra field selected val
You 're welcome :)
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.