2014-10-07 30 views
0

我在前端为特定类型的节点操作创建了一些自定义页面。这是我的页面回调:Drupal 7.31 - 节点文件类型字段的问题

function vintranet_talk_edit_entry_page_callback($sNid) { 
    module_load_include('inc', 'node', 'node.pages'); 

    $oNode = node_load($sNid); 

    return drupal_get_form('page_node_form', $oNode); 
} 

我的节点有一个带有文件附件的字段。

配置:

'vintranet_talk_attachments' => array(
    'field_name'  => 'vintranet_talk_attachments', 
    'label'   => t('Attachments'), 
    'type'   => 'file', 
    'cardinality' => -1, 
), 

实例:

'vintranet_talk_attachments' => array(
    'field_name'  => 'vintranet_talk_attachments', 
    'label'   => t('Attachments'), 
    'entity_type' => 'node', 
    'bundle'   => 'intranet_talk_page', 
    'widget'   => array(
     'type' => 'file_mfw', 
    ), 
    'settings'  => array(
     'max_filesize'  => 10, 
     'file_directory'  => 'intranet/talk', 
     'file_extensions' => 'jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar', 
     'description_field' => 1, 
    ), 
    'display'  => array(
     'default' => array(
      'type' => 'file_table', 
     ), 
    ), 
), 

我的第一个问题是,当我要上传JPG文件模块安装完成后,系统会发送此消息: enter image description here

好吧...我要检查Structure中的特定字段设置,我看到这个:

enter image description here

为什么地狱它是这样保存的?

Okaaaaay ....所以我就jpg, png, gif, pdf, zip, doc, rtf, xdoc, rar更改此表单字段的值,保存和尝试上传的图像一个更多的时间......

enter image description here

.... clickin“上传“按钮.... aaaaandd ....

enter image description here

....烨....这是我的第二个问题:/。不知道为什么它不起作用。另一方面,在后端,“上传”按钮完美工作。我错过了什么吗?

(在Drupal的7.31版工作)

菜单节点添加路径:

array(
    'mynode/add/path' => array(
      'title'    => 'Title - new entry', 
      'page callback'  => 'vintranet_talk_add_entry_page_callback', 
      'file'    => 'vintranet_talk.pages.inc', 
      'access arguments' => array('vintranet_talk_add_entry'), 
     ), 
); 
+1

通过 '马吕斯·伊利耶' 看看第二个答案在这个堆栈的问题:http://stackoverflow.com/questions/5344754/drupal-7-how-to-display-node-add-sometype-form-on-another-page – 2pha 2014-10-07 12:02:16

+0

@ 2pha好吧,但我有'文件'在这个特定的菜单路径中键(更新q最后的问题)。如果我将更改'文件',页面会粉碎:(。 – 2014-10-07 13:17:22

回答

1

回答我的问题:

function hook_menu_alter(&$aItems) { 
    $sNodePath = drupal_get_path('module', 'node'); 

    $aItems['file/ajax']['file path'] = $sNodePath; 
    $aItems['file/ajax']['file']   = 'node.pages.inc'; 
    $aItems['system/ajax']['file path'] = $sNodePath; 
    $aItems['system/ajax']['file']  = 'node.pages.inc'; 
} 
+0

很高兴你把它分类:) – 2pha 2014-10-07 13:44:07