本文整理汇总了PHP中taxonomy_vocabulary_machine_name_load函数的典型用法代码示例。如果您正苦于以下问题:PHP taxonomy_vocabulary_machine_name_load函数的具体用法?PHP taxonomy_vocabulary_machine_name_load怎么用?PHP taxonomy_vocabulary_machine_name_load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了taxonomy_vocabulary_machine_name_load函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkTerms
public static function checkTerms($vocabName, $termName)
{
/*@param $vocabName
*@param $termName
*@return $tid
*/
$vocab = taxonomy_vocabulary_machine_name_load($vocabName);
$vid = $vocab->vid;
//check term
$checkTerm = taxonomy_get_term_by_name($termName, $vocabName);
if (empty($checkTerm)) {
$term = new stdClass();
$term->name = $termName;
$term->vid = $vid;
taxonomy_term_save($term);
$termArray = taxonomy_get_term_by_name($termName, $vocabName);
$term = current($termArray);
$tid = $term->tid;
return $tid;
} else {
$term = current($checkTerm);
$tid = $term->tid;
return $tid;
}
}
示例2: jollyness_preprocess_html
function jollyness_preprocess_html(&$vars)
{
//Process portfolio color
if ($portfolio_category = taxonomy_vocabulary_machine_name_load('portfolio_category')) {
$terms = taxonomy_get_tree($portfolio_category->vid);
$less = new lessc();
$css = '';
$color = '';
$class = '';
foreach ($terms as $t) {
$term = taxonomy_term_load($t->tid);
$class = drupal_html_class($t->name);
if (!empty($term->field_color)) {
foreach ($term->field_color as $v) {
$color = $v[0]['value'];
break;
}
}
if ($color) {
$css .= ".dexp-masonry-filter,.dexp-portfolio-filter{.{$class} span:before{background-color: {$color} !important;}}";
$css .= ".{$class} .portfolio-item-overlay{background-color: rgba(red({$color}), green({$color}), blue({$color}), 0.7) !important;}";
}
}
$css = $less->compile($css);
drupal_add_css($css, array('type' => 'inline'));
}
}
示例3: _bootstrap_theme_category_contents
function _bootstrap_theme_category_contents($vocab_name)
{
global $user;
//$contents = bootstrap_theme_get_category_contents(NODE_PUBLISHED, $user);
$output = '';
$myvoc = taxonomy_vocabulary_machine_name_load($vocab_name);
$tree = taxonomy_get_tree($myvoc->vid);
$depth = 0;
$output .= '<div>Vocabulary terms under <a href="' . base_path() . 'category/' . $vocab_name . '" class="category-title">' . $myvoc->name . '</a>. Click on term you want to search content for.</div>
<div style="float:right;"><a href="' . base_path() . '" class="btn btn-primary form-submit">Back</a></div><br>';
$output .= '<ul>';
foreach ($tree as $term) {
if ($term->depth > $depth) {
$output .= '<ul>';
$depth = $term->depth;
}
if ($term->depth < $depth) {
$output .= '</ul>';
$depth = $term->depth;
}
//$output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . '</li>';
$output .= '<li>' . l($term->name, 'taxonomy/term/' . $term->tid) . "<br>";
$output .= '<div>' . $term->description . '</div></li>';
}
$output .= '</ul>';
return $output;
}
示例4: prepare
/**
* Override Migration::prepare().
*
* Set the term parent for heirarchical terms
*
* @param $term
* @param $row
*/
public function prepare($term, $row)
{
// Handle og_vocab
$vocab_name = $this->bundle;
if (!($vocabulary = taxonomy_vocabulary_machine_name_load($vocab_name))) {
// Create a new vocabulary
$vocabulary = (object) array('name' => 'Meter categories for ' . $row->account_id, 'description' => 'Meter categories for ' . $row->account_id, 'machine_name' => $vocab_name);
taxonomy_vocabulary_save($vocabulary);
}
// Create an OG-vocab and relate new vocabulary with OG.
$account_id = $term->account_id['destid1'];
$settings = array('cardinality' => 1, 'required' => TRUE);
// Loop for all meter content-types and create og-vocabulary.
$node_types = node_type_get_types();
foreach ($node_types as $content_type) {
if (strpos($content_type->type, '_meter') === FALSE) {
// Not a meter type, skip.
continue;
}
$og_vocab = og_vocab_create_og_vocab($vocabulary->vid, 'node', $content_type->type, OG_VOCAB_FIELD, $settings);
$og_vocab->save();
}
og_vocab_relation_save($vocabulary->vid, 'node', $account_id);
// Save vocabulary id.
$term->vid = $vocabulary->vid;
// Handle parent.
$term->name = ucwords(trim($term->name));
$parent = ucwords(trim($row->parent));
$parent_term = taxonomy_get_term_by_name($parent, $vocab_name);
$parent_term = reset($parent_term);
if ($parent_term) {
$term->parent = $parent_term->tid;
}
}
示例5: hook_draw_chart_alter
/**
* Implements hook_draw_chart_alter().
*/
function hook_draw_chart_alter(&$settings)
{
foreach ($settings as $chart) {
if (isset($chart['chart']['chartCategory']) && !empty($chart['chart']['chartCategory'])) {
// Geting the count result by vocabulary machine name.
$voc = taxonomy_vocabulary_machine_name_load('categories');
$tree = taxonomy_get_tree($voc->vid);
$header = array();
foreach ($tree as $term) {
// Feeds the header with terms names.
$header[] = $term->name;
$query = db_select('taxonomy_index', 'ti');
$query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
// Feeding the terms with the node count.
$terms[] = $query->countQuery()->execute()->fetchField();
}
$columns = array('Content per category');
$rows = array($terms);
// Replacing the data of the chart.
$chart['chart']['chartCategory']['header'] = $header;
$chart['chart']['chartCategory']['rows'] = $rows;
$chart['chart']['chartCategory']['columns'] = $columns;
// Adding a colors attribute to the pie.
$chart['chart']['chartCategory']['options']['colors'] = array('red', '#004411');
}
}
}
示例6: getTaxonomyTermsAsSelectOptions
/**
* @param \stdClass $config
* @return array
*/
protected function getTaxonomyTermsAsSelectOptions($config)
{
$answer = [];
if (isset($config->vocabulary) && isset($config->level)) {
/** @var \stdClass $vocabulary */
if ($vocabulary = taxonomy_vocabulary_machine_name_load($config->vocabulary)) {
$tree = $tree = taxonomy_get_tree($vocabulary->vid, 0, null, true);
dpm($tree, "FLAT TREE");
/*
if(count($terms) == 1) {
$term = array_pop($terms);
if(isset($term->description)) {
$answer = $term->description;
if($stripHtml) {
$answer = strip_tags($answer);
}
}
}*/
} else {
drupal_set_message("Vocabulary not found by name: " . $config->vocabulary, 'warning');
}
} else {
drupal_set_message("Vocabulary or Level not set in config: " . json_encode($config), 'warning');
}
return $answer;
}
示例7: synchronize
public function synchronize(NodeInterface $node, Context $context, $dirtyAllowed = false)
{
/* @var $node EntityNode */
$machineName = $node->getBundle();
$object = $node->getValue();
if (!is_array($object)) {
$object = [];
}
if (empty($object['description'])) {
$description = '';
} else {
$description = $object['description'];
}
if ($node->isMerge() && ($existing = $this->getExistingObject($node, $context))) {
$info = ['machine_name' => $machineName, 'description' => $description] + $object + $existing;
} else {
$info = ['machine_name' => $machineName, 'description' => $description] + $object + self::$defaults;
if ($vocabulary = taxonomy_vocabulary_machine_name_load($machineName)) {
// So an existing object is here, but the vid parameter is
// actually never loaded (we don't want to export it when we
// are building a yml file) - therefore we need to load it
// once again. In case we didn't set the vid, the taxonomy
// save method will attempt an SQL INSERT and cause bad SQL
// STATE errors (constraint violation)
$info['vid'] = $vocabulary->vid;
}
}
if (empty($info['name'])) {
$context->logWarning(sprintf('%s: has no name', $node->getPath()));
$info['name'] = $machineName;
}
taxonomy_vocabulary_save((object) $info);
}
示例8: setPropertyValues
/**
* Overrides DataProviderEntity::setPropertyValues().
*
* This class is created to override this method. This method is overridden to
* add the vocabulary ID based on the vocabulary machine name when creating a
* taxonomy term.
*/
protected function setPropertyValues(\EntityDrupalWrapper $wrapper, $object, $replace = FALSE)
{
$term = $wrapper->value();
if (empty($term->vid)) {
$vocabulary = taxonomy_vocabulary_machine_name_load($term->vocabulary_machine_name);
$term->vid = $vocabulary->vid;
}
parent::setPropertyValues($wrapper, $object, $replace);
}
示例9: getOptionsfrom
function getOptionsfrom($taxonomy)
{
$terms = array();
$myvoc = taxonomy_vocabulary_machine_name_load($taxonomy);
$tree = taxonomy_get_tree($myvoc->vid);
foreach ($tree as $term) {
array_push($terms, $term->name);
}
return $terms;
}
示例10: build
public function build()
{
if ($voc = taxonomy_vocabulary_machine_name_load($this->bundle)) {
$voc->name = $this->label;
$voc->description = $this->description;
} else {
$voc = (object) array('machine_name' => $this->bundle, 'name' => $this->label, 'description' => $this->description);
}
taxonomy_vocabulary_save($voc);
}
示例11: setPropertyValues
/**
* Overrides \RestfulEntityBase::setPropertyValues().
*
* Set the "vid" property on new terms.
*/
protected function setPropertyValues(EntityMetadataWrapper $wrapper, $null_missing_fields = FALSE) {
$term = $wrapper->value();
if (!empty($term->tid)) {
return;
}
$vocabulary = taxonomy_vocabulary_machine_name_load($term->vocabulary_machine_name);
$term->vid = $vocabulary->vid;
parent::setPropertyValues($wrapper, $null_missing_fields);
}
示例12: exploreworld_preprocess_page
function exploreworld_preprocess_page(&$vars)
{
$voc = taxonomy_vocabulary_machine_name_load('travel_destinations');
$taxonomy = taxonomy_get_tree($voc->vid);
$items = array();
foreach ($taxonomy as $row) {
$items[] = $row->name;
}
$vars['custom_item_list'] = theme('custom_item_list', array('items' => $items));
$obj = menu_get_object();
if (is_object($obj)) {
$vars['theme_hook_suggestions'][] = 'page__' . $obj->type;
}
}
示例13: _create_vocabs
function _create_vocabs()
{
$new_vocabs = array('vocab_machine_name_1' => 'Human readable name 1', 'vocab_machine_name_2' => 'Human readable name 2', 'vocab_machine_name_3' => 'Human readable name 3');
foreach ($new_vocabs as $vocab_name => $name) {
if (!taxonomy_vocabulary_machine_name_load($vocab_name)) {
$vocab = new stdClass();
$vocab->name = $name;
$vocab->machine_name = $vocab_name;
taxonomy_vocabulary_save($vocab);
}
//if
}
//foreach
}
示例14: _taxonomy_options
function _taxonomy_options($machine_name, $default = '')
{
$vocabulary = taxonomy_vocabulary_machine_name_load($machine_name);
$tree = taxonomy_get_tree($vocabulary->vid);
if (!empty($default)) {
$options[0] = $default;
} else {
$options = array();
}
foreach ($tree as $item) {
$options[$item->tid] = str_repeat('-', $item->depth) . $item->name;
}
return $options;
}
示例15: hook_analytics_dashboard
/**
* Implements hook_analytics_dashboard().
*/
function hook_analytics_dashboard()
{
$voc = taxonomy_vocabulary_machine_name_load('categories');
$tree = taxonomy_get_tree($voc->vid);
$header = array();
foreach ($tree as $term) {
$header[] = $term->name;
$query = db_select('taxonomy_index', 'ti');
$query->condition('ti.tid', $term->tid, '=')->fields('ti', array('nid'));
$terms[] = $query->countQuery()->execute()->fetchField();
}
$columns = array('Ideas in category');
$rows = array($terms);
$settings = array();
$settings['chart']['chartCategory'] = array('header' => $header, 'rows' => $rows, 'columns' => $columns, 'weight' => -10, 'chartType' => 'PieChart', 'options' => array('curveType' => "function", 'is3D' => TRUE, 'forceIFrame' => FALSE, 'title' => 'Ideas per category', 'width' => 500, 'height' => 300));
return draw_chart($settings);
}