function ds_fields_examples in Display Suite 6.3
Same name and namespace in other branches
- 6 includes/ds.fields.inc \ds_fields_examples()
- 6.2 includes/ds.fields.inc \ds_fields_examples()
Show examples for a field by loading the objects and preprocess variables.
1 string reference to 'ds_fields_examples'
- _ds_ui_menu in includes/
ds.registry.inc - Return menu items and import default settings.
File
- includes/
ds.fields.inc, line 740 - Manage fields.
Code
function ds_fields_examples($module) {
// Check on devel.
$devel = drupal_get_path('module', 'devel');
if (empty($devel)) {
return t('You need the devel module for this on your site, however, it does not have to be enabled. You can download the module from <a href="!url">!url</a>.', array(
'!url' => 'http://drupal.org/project/devel',
));
}
// Load it if needed and show the rest.
_ds_fields_load_devel();
$output = '';
$api_info = ds_api_info($module);
if (isset($api_info['types'])) {
$types = array();
foreach ($api_info['types']() as $tkey => $type) {
$types[$tkey] = array(
'title' => check_plain($type->name),
'href' => DS_PATH_MODULES . '/' . $module . '/fields-examples',
'query' => array(
'type' => $tkey,
),
);
}
}
$selects = theme('links', $types);
$output = '<div><h2 style="margin-bottom: 10px;">' . t('Object types') . '</h2>' . $selects . '</div>';
$output .= '<div style="margin: 10px 0px 10px 0px; padding-top: 10px; border-top: 1px solid #ddd">' . t('Select a type to see properties from it. The output from the objects is usually the object individually (e.g. a full node, comment, user ...). If you pass the parameter id in the URL, you can select an object with that id instead of a random one. Note that variables ending with "_rendered" are not usable when creating preprocess fields.') . '</div>';
if (isset($_GET['type']) && isset($types[$_GET['type']])) {
$output .= _ds_fields_examples_render($api_info, $_GET['type'], $output);
}
return $output;
}