2011-11-29 87 views
3

我有了所谓的[股票]自定义字段的自定义内容类型编辑各个领域创建一个页面来从一个自定义的内容类型(D7)

我想有一个页面,显示我的所有节点[stock]值列表中,并允许我更改该值。这可能吗?

任何建议,将不胜感激

+0

您也可以尝试这个模块http://drupal.org/project/views_bulk_operations –

+0

添加尽可能多的领域+1非常好的主意我可以自己使用它,只需写一个模块来完成它我将在完成后发布代码 – Clive

回答

3

那么我打算写一个模块,但像往常一样,Drupal有人殴打我!

你应该下载并安装Views,还有(非常好的)Slick Grid module。它提供了一个视图类型(光滑网格),它将创建一个内容表,并为字段启用内嵌编辑。对于更复杂的字段类型,它提供了一个用于编辑的模式弹出窗口。

我花了10分钟,以创建具有下面的输出,这让我在表中直接通过双击单元格编辑字段的看法:

Views Output

的内容自动保存到数据库,当你再次点击编辑单元时,它全部通过AJAX处理,这使得它非常令人愉快。

你可以为你喜欢的电网,所以我认为这正是你追求的:)

+0

完美,谢谢@Clive – Cybercampbell

+0

我只是得到一个空白的框。有任何想法吗?对于这个模块似乎没有任何帮助。 – Cybercampbell

+0

我的不好,我没有保持图书馆目录“slickgrid”......所有目前看起来都很棒。 – Cybercampbell

1

是的,它是我做了这样的事情来得到它的工作。在你的情况下,你将不得不修改sql查询来获取你的自定义字段。您还需要修改$headers$rows阵列以包含您需要显示的内容,但我认为您明白了。

// first I create my own module hooking the menu 
function custom_menu() { 
    $items['admin/custom-content'] = array(
     'title' => t('Custom Content'), 
     'type' => MENU_NORMAL_ITEM,  
     'access arguments' => array('access content'), 
    ); 
    $items['admin/custom-content/product'] = array(
     'title' => t('Products'), 
     'type' => MENU_NORMAL_ITEM, 
     'access arguments' => array('access content'), 
     'page callback' => 'custom_view_products' 
    ); 
      return $items; 
    } 
    // the above will add a new admin menu link called Custom Content 
    // then I have a callback method for the menu item 
    function custom_view_products() { 
     // setup the header for the form 
     $headers = array(
     array('data' => 'Title', 'field' => 'title', 'sort' => 'asc'), 
     array('data' => 'Published') 
    ); 
     // 
     $query = "SELECT n.* FROM {node} n ". 
        "WHERE n.type = 'product' ORDER BY n.title ASC"; 

    // 
    $rows = array(); 
    if(($results = db_query($query)->fetchAll())) { 
     foreach ($results as $node) { 
      $rows[] = array(
       'data' => array(
       l($node->title, 'node/'. $node->nid .'/edit'), 
       $node->status 
       ), 'class' => array('published') 
      ); 
     } 
     } 
    $html = theme('table', 
     array(
      'header' => $headers, 
      'rows'=>$rows, 
      'caption' => '', 
      'sticky' => FALSE, 
      'empty' => 'No products located...', 
     ) 
    ); 
    return $html; 
} 
+0

感谢@Krister,但我不认为我还在那里,但我的drupal技能。但要保存这个下雨天。 – Cybercampbell

相关问题