taxonomy_preview_terms
modules/taxonomy/taxonomy.module, строка 570
- Версии
- 6
taxonomy_preview_terms($node)
Helper function to convert terms after a preview.
After preview the tags are an array instead of proper objects. This function
converts them back to objects with the exception of 'free tagging'
terms,
because new tags can be added by the user before preview and those do not
yet exist in the database. We therefore save those tags as a string so
we can fill the form again after the preview.
Код
<?php
function taxonomy_preview_terms($node) {
$taxonomy = array();
if (isset($node->taxonomy)) {
foreach ($node->taxonomy as $key => $term) {
unset($node->taxonomy[$key]);
// A 'Multiple select' and a 'Free tagging' field returns an array.
if (is_array($term)) {
foreach ($term as $tid) {
if ($key == 'tags') {
// Free tagging; the values will be saved for later as strings
// instead of objects to fill the form again.
$taxonomy['tags'] = $term;
}
else {
$taxonomy[$tid] = taxonomy_get_term($tid);
}
}
}
// A 'Single select' field returns the term id.
elseif ($term) {
$taxonomy[$term] = taxonomy_get_term($term);
}
}
}
return $taxonomy;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии