/** * Renders the field * * @return string */ function render() { $random_keys = array('name' => $this->field_id, 'latitude' => Helper::getRandomString(), 'longitude' => Helper::getRandomString()); $values = array('name' => isset($this->field_data['name']) ? $this->field_data['name'] : '', 'latitude' => isset($this->field_data['latitude']) ? $this->field_data['latitude'] : '', 'longitude' => isset($this->field_data['longitude']) ? $this->field_data['longitude'] : ''); $html = '<div class="map"'; // add in per-field settings $settings = array(); foreach ($this->field_config as $setting => $value) { if (!in_array($setting, $this->allowed_settings) || is_null($value)) { continue; } $settings[$setting] = $value; } // if we found something, add the configuration to the element if (count($settings)) { $html .= " data-location-configuration='" . json_encode($settings) . "'"; } $html .= '></div>'; $html .= '<div class="entry">'; $html .= ' <div class="name">'; $html .= ' <p>'; $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][name', array('display' => Localization::fetch('location_name')), $values['name'], NULL, NULL, $random_keys['name']); $html .= ' </p>'; $html .= ' </div>'; $html .= ' <div class="coordinates">'; $html .= ' <p class="latitude">'; $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][latitude', array('display' => Localization::fetch('latitude')), $values['latitude'], NULL, NULL, $random_keys['latitude']); $html .= ' </p>'; $html .= ' <p class="longitude">'; $html .= Fieldtype::render_fieldtype('text', 'yaml][' . $this->field . '][longitude', array('display' => Localization::fetch('longitude')), $values['longitude'], NULL, NULL, $random_keys['longitude']); $html .= ' </p>'; $html .= ' </div>'; $html .= '</div>'; return $html; }
public function control_panel__add_to_head() { if (URL::getCurrent(false) != '/publish' && URL::getCurrent(false) != '/member') { return; } $config = array('max_files' => 1, 'allowed' => array(), 'destination' => 'UPLOAD_PATH', 'browse' => false); $fieldtype = Fieldtype::render_fieldtype('file', 'markituploader', $config, null, null, 'markituploader', 'markituploader'); $template = File::get($this->getAddonLocation() . 'views/modal.html'); return $this->js->inline('Statamic.markituploader = ' . json_encode(Parse::template($template, compact('fieldtype'))) . ';'); }
$value['display'] = Localization::fetch('password'); } } // If no display label is set, we'll prettify the fieldname itself $value['display'] = array_get($value, 'display', Slug::prettify($key)); ?> <div class="<?php echo implode($wrapper_classes, ' '); ?> " <?php echo implode($wrapper_attributes, ' '); ?> > <?php print Fieldtype::render_fieldtype($fieldtype, $key, $value, $val, tabindex(), $input_key, null, $error); ?> </div> <?php } ?> </div> <div id="publish-action" class="footer-controls push-down"> <input type="submit" class="btn" value="<?php echo Localization::fetch('save'); ?> " id="publish-submit"> </div>
</b></p> <pre> global: variable: default value - or - variable_name: </pre> <?php } else { ?> <div class="input-block input-<?php echo $type; ?> "> <?php print Fieldtype::render_fieldtype($type, $key, $field, $value, tabindex(), $input_key); ?> </div> <?php } ?> <?php } ?> </div> <div id="publish-action" class="footer-controls push-down"> <input type="submit" class="btn" value="Save & Publish" id="publish-submit"> </div> </form> </div>
public function render_empty_row($index) { $row_num = $index + 1; $row = "<tr>"; $row .= "<th class='row-count drag-indicator'><div class='count'>{$row_num}</div><a href='#' class='grid-delete-row confirm'><span class='ss-icon'>delete</span></a></td></th>"; foreach ($this->field_config['fields'] as $cell_field_name => $cell_field_config) { $celltype = array_get($cell_field_config, 'type', 'text'); $default = array_get($cell_field_config, 'default', ''); $name = $this->field . '][' . $index . '][' . $cell_field_name; $row .= "<td class='cell-{$celltype}' data-default='{$default}'>" . Fieldtype::render_fieldtype($celltype, $name, $cell_field_config, $default, null, '[yaml]', 'rename_me') . "</td>"; } $row .= "</tr>\n"; return $row; }
/** * Build fieldtypes with data from front matter * * @param int $i The index of the field in the set * @param array $set The set's field config * @param array $data This set's front matter data * @return array */ private function fieldtypes($i, $set, $data) { $set_fields = array_get($set, 'fields', array()); $fieldtypes = array(); foreach ($set_fields as $field_name => $field) { $key = "[yaml][{$this->field}][{$i}]"; $id = $field_name . '_' . $i; $field_data = array_get($data, $field_name); $field_type = array_get($field, 'type', 'text'); $field_config = $set['fields'][$field_name]; $field_config['display'] = array_get($field_config, 'display', Slug::prettify($field_name)); if ($field_type == 'grid') { $field_name = "{$this->field}][{$i}][{$field_name}"; } $fieldtypes[] = array('type' => $field_type, 'field_name' => $key, 'fieldtype' => Fieldtype::render_fieldtype($field_type, $field_name, $field_config, $field_data, null, $key, $id)); } return $fieldtypes; }
public function render_empty_row($index) { $row = "<tr>"; $row .= "<th class='row-count drag-indicator'><div class='count'>{$index}</div><a href='#' class='grid-delete-row confirm'><span class='ss-icon'>delete</span></a></td></th>"; foreach ($this->field_config['fields'] as $cell_field_name => $cell_field_config) { $celltype = $cell_field_config['type']; $default = isset($cell_field_config['default']) ? $cell_field_config['default'] : ''; if ($cell_field_config['type'] == 'file') { //$name = $cell_field_name.'[0]'; $name = $this->field . '][0][' . $cell_field_name; } else { $name = $this->field . '][0][' . $cell_field_name; } $row .= "<td class='cell-{$celltype}' data-default='{$default}'>" . Fieldtype::render_fieldtype($celltype, $name, $cell_field_config, $default) . "</td>"; } $row .= "</tr>\n"; return $row; }
public function render_empty_row($index) { $row_num = $index + 1; $row = "<tr>"; $row .= "<th class='row-count drag-indicator'><div class='count'>{$row_num}</div><a href='#' class='grid-delete-row confirm'><span class='ss-icon'>delete</span></a></td></th>"; foreach ($this->field_config['fields'] as $cell_field_name => $cell_field_config) { $celltype = array_get($cell_field_config, 'type', 'text'); $default = array_get($cell_field_config, 'default', ''); $name = $this->field . '][' . $index . '][' . $cell_field_name; // This makes the config a little different from "real" fields // If a fieldtype is leveraging caching, one of these fields will throw it off. // Making this a bit more unique will prevent that. $cell_field_config['grid_placeholder_row'] = true; $row .= "<td class='cell-{$celltype}' data-default='{$default}'>" . Fieldtype::render_fieldtype($celltype, $name, $cell_field_config, $default, null, '[yaml]', 'rename_me') . "</td>"; } $row .= "</tr>\n"; return $row; }