Skip to content

Instantly share code, notes, and snippets.

@iamrobert
Created June 13, 2016 17:39
Show Gist options
  • Save iamrobert/c45e691befad382a3eb6023312716b14 to your computer and use it in GitHub Desktop.
Save iamrobert/c45e691befad382a3eb6023312716b14 to your computer and use it in GitHub Desktop.
CALL RAW FIELD in ITEM -> field name is type
<?php $fieldname = 'type';
if ( !isset($item->fields[$fieldname]->parameters) ) {
FlexicontentFields::loadFieldConfig($item->fields[$fieldname], $item);
}
$extra_props = array(); // use $extra_props = array('image'); // if radioimage or checkboximage field
$elements = FlexicontentFields::indexedField_getElements( $item->fields[$fieldname], $item, $extra_props );
if (!empty($elements)) foreach ($elements as $el) {
if ( @unserialize($el)!== false || $el=== 'b:0;' ) $el = unserialize($el);
//var_dump($el);
// CALL STD OBJECTS
echo $el->value;
echo $el->text;
}
?>
@iamrobert
Copy link
Author

iamrobert commented Feb 9, 2018

Check if field exists or not - change 'top_banner' to field name

<?php if (isset($this->item->fields['top_banner']->display)&&!empty($this->item->fields['top_banner']->display)):?>

<h1>CODE</h1>

	<?php endif;?>	

@iamrobert
Copy link
Author

Insert FIELD in FLEXICONTENT UNIVERSAL Module
<?php if (isset($item->_row->fieldvalues[119][0])) :?> <?php //TITLE (CHN) if($item->_row->fieldvalues[119][0] != null): ?> <br><span class="chn"><?php echo $item->_row->fieldvalues[119][0]; ?></span> <?php endif; ?> <?php endif; ?>

@iamrobert
Copy link
Author

EXTRACT IMAGE URL from SRC Attribute in FLEXICONTENT Universal Module


$doc = new DOMDocument();
$doc->loadHTML(FlexicontentFields::getFieldDisplay( $item, 'blog_cat_image' ));
$imageTags = $doc->getElementsByTagName('img');

foreach($imageTags as $tag) {
    echo $tag->getAttribute('src');
}

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