Skip to content

Instantly share code, notes, and snippets.

@uglyeoin
Last active June 18, 2018 14:13
Show Gist options
  • Save uglyeoin/11133dd0e2dc03db16be80c21a5275a6 to your computer and use it in GitHub Desktop.
Save uglyeoin/11133dd0e2dc03db16be80c21a5275a6 to your computer and use it in GitHub Desktop.
<?php echo $this->item->jcfields[0]->value; ?>
## The number is the ID of the field NOT the number in the array
<?php echo $item->jcfields[JText::_('JCFIELDS_FIELDNAME')]->value; ?>
## FIELDNAME is the NAME of the field as you have saved it
## or turn core fields into names
<?php
// Turn fields from array numbers into field names. I usually stick this in the head somewhere.
foreach($this->item->jcfields as $jcfield){
$this->item->field[$jcfield->name] = $jcfield;
}
?>
// Call the field by the name. With error checking if it is empty.
// This way we can add markup around it and it will only appear if the field is in use.
<?php
if (isset($this->item->field['price']->value) and !empty($this->item->field['price']->value))
{echo "Value: " . $this->item->field['price']->value;};
?>
Copy link

ghost commented May 24, 2018

@uglyeoin
Copy link
Author

uglyeoin commented Jun 9, 2018

@YMages yes :) Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment