如何从CCK的select field中取得value list

-- Submitted by Admin on Sat, 05/29/2010 - 21:17

有时候会有这种需求,内容类型是用Drupal系统的内容类型机制创建的,但是由于创建表单的样式定制性太强,默认的创建表单结构不好调整,所以要自定义一个创建表单。

这时候如果有select field,我们要取出里面的value list使用,而不要再次重写一遍。

我将这个方法写成了API,函数代码如下:

<?php
//从cck的select字段中取得valuelist
function get_select_value_list($field_name) {
 
$sql = "SELECT global_settings FROM {content_node_field} WHERE field_name ='%s'";
 
$result = db_result(db_query($sql, $field_name));
 
$result = unserialize($result);
 
$result = $result[allowed_values];
 
$results = explode("\r\n", $result);
  if(!empty(
$results)) {
    foreach(
$results as $value) {
     
$rows[$value] = $value;
    }
  }
  return
$rows;
}
?>

Comments

请问:怎么实现,多条件查询的VIEWS呢?

请问:怎么实现,多条件查询的VIEWS呢?

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Allowed HTML tags: <a> <em> <strong> <code> <cite> <ul> <ol> <li> <dl> <dt> <dd> <img> <ebmed>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
1 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.