private function content_ajax_page_fc($fcid) { $fcitem = \Drupal\field_collection\Entity\FieldCollectionItem::load($fcid); $target = WG::entity_get_field_value($fcitem, 'field_target'); preg_match('%^([^:]+)://([0-9]+)$%', $target, $m); $itemtype = $m[1]; $id = $m[2]; switch ($itemtype) { case 'public318': $identifier = $id; $text = WG::entity_get_field_formatted_text($fcitem, 'field_annotation'); $stylename = 'large'; $icon_uri = _expo_public318_get_icon_uri($identifier); $icontag = WG::render_styled_image($icon_uri, $stylename); $output = '<div class="sticky-fc-public318">' . '<div class="collicon">' . _expo_coll_url($identifier, $icontag) . '</div>' . '<div class="colltext">' . $text . '</div>' . '</div>'; break; case 'storynode': $nid = $id; $story = node_load($nid); $v = entity_view($story, 'ajaxpage'); $output = render($v); break; default: $tag = "<div class=\"sticky\" id=\"sticky_{$pos}\">" . $itemtype . $pos . "</div>"; } $build = ['#markup' => $output]; return $build; }
public function content_public318edit($id) { $entity = node_load($id); $r = ''; if ($entity) { $form = ['items' => array()]; $cnt = count($entity->field_collitem); for ($i = 0; $i < $cnt; $i++) { $fcid = $entity->field_collitem[$i]->value; $fcitem = \Drupal\field_collection\Entity\FieldCollectionItem::load($fcid); $target = WG::entity_get_field_value($fcitem, 'field_target'); $annotation = WG::entity_get_field_value($fcitem, 'field_annotation'); extract(_expo_extract_collitem_target($target)); $identifier = $id; //$collitems[] = ['target'=>$target, 'annotation'=>$annotation]; $delta = microtime(); $delta = preg_replace('%[^0-9]%', '', $delta); $form['items'][$delta] = ['#type' => 'container', '#prefix' => '<li><div class="collitem-element-wrapper" id="collitem-index-' . $delta . '">', '#suffix' => '</div></li>']; $this->_collitem_element_make2($form['items'][$delta], $delta, $identifier, $fcid, $annotation); } $r .= render($form); } echo $r; die; }