2
我有一个基于分类的具有类别字段的内容类型。但我希望编辑只能选择每个内容片段的子类别,而不是父类别。我怎么做?Drupal 7:如何在添加内容时仅允许选择分类项目的子级别作为类别
我有一个基于分类的具有类别字段的内容类型。但我希望编辑只能选择每个内容片段的子类别,而不是父类别。我怎么做?Drupal 7:如何在添加内容时仅允许选择分类项目的子级别作为类别
我有类似这样看,如果可以帮助你在某种代码...它得到孩子的家长在一个数组,如果你打算使用自定义模块,使之...
$tree_type = taxonomy_get_tree(3);
$childs["selected"]="All";
foreach($tree_type as $key =>$value) {
$temp_ = taxonomy_term_load($value->parents[0]); //IF parent is set already
if($value->parents[0]==0) { //if no any parent taxonomy
if(is_object($temp_)==TRUE) { //CHECK IF SINGLE iTEM PARENT
if(isset($childs[$temp_->name])) { //if array key is already set
if(is_array($key)!=FALSE) { //if value is not an array
$childs[$temp_->name][$tree_type[$key]->tid]=array($key=>$value->name); // set the parent child array
}
}else {
if(is_array($key)!=FALSE) { //if value is not an array
$childs[$temp_->name][$tree_type[$key]->tid]=array($key=>$value->name); // set the parent child array
}
}
}else
{
$childs[$value->name]=array();
$childs[$value->name][$tree_type[$key]->tid]="-".$value->name;
//drupal_set_message("-------<pre>".$value->name."</pre>-------");
//drupal_set_message("<pre>".print_r($childs,true)."</pre>");
}
}else {
$childs[$temp_->name][$tree_type[$key]->tid]=$value->name; //$childs[$temp_->tid]=$temp_->name;
}
}