2013-08-16 63 views
0

我正在嘗試構建一個類似Facebook的畫廊。這是我現在能夠做的:Drupal視圖中的評論表

1)我創建了帶標題和說明字段的內容類型相冊。

2)然後我創建的內容類型的照片,與場圖像和字段專輯名稱,引用(1)

3)然後,我添加一些示例性內容創建的節點。假設我創建了專輯A和B,以及參照專輯A的照片1,2,3和4以及參考專輯B的照片5,6,7和8。

4)我創建了一個視圖,其中顯示了所有專輯由特定用戶創建,並顯示每個相冊的縮略圖。在我的情況是這樣的:

專輯的名稱: 照片1,2,3,4

專輯B名稱: 照片5,6,7,8

到目前爲止好,我對下一個有問題。

5)我想創建覆蓋每個專輯節點使用視圖,我想顯示給定的每張專輯的所有照片,與傳呼機一次只顯示1張照片。這不是問題,我只需要最後一件事,每張照片(而不是專輯)的所有評論意見表。所以我有1到8頁的傳呼機,如果我從照片1到2,我想要改變評論表格,以便它現在屬於照片2。

我試過主題化它的觀點,行樣式輸出部分,我試圖用comment_formarray('nid' => $nid)

Notice: Trying to get property of non-object in comment_form() (line 1876 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). 
Notice: Trying to get property of non-object in locale_form_comment_form_alter() (line 403 of D:\Programy\WebServ\httpd\fitspace\modules\locale\locale.module). 

我搜索在互聯網上找到解決方案,我得到很多的錯誤,這種方法,例如但沒有成功,所以你是我最後的希望。

回答

0

comment_form()期望$comment參數是一個對象,並且您正在傳遞數組。

嘗試

$comment = new stdClass(); 
$comment->nid = $nid; 
$form = drupal_get_form('comment_form', $comment); 
print drupal_render($form); 
0

我嘗試這樣做:

$nid=$fields['nid']->content; 
$comment = new stdClass(); 
$comment->nid = $nid; 
$form = drupal_get_form('comment_form', $comment); 
print drupal_render($form); 

獲得例如以下信息:

注意:試圖讓非對象的財產comment_form()(行1876年D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module)。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module)的第1878行中獲取非對象的屬性。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module)的2009行中獲取非對象的屬性。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module的第2023行)中獲取非對象的屬性。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module的第2031行)中獲取非對象的屬性。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module)的2037行中獲取非對象的屬性。注意:試圖在comment_form()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ comment \ comment.module的第2043行)中獲取非對象的屬性。注意:試圖在locale_form_comment_form_alter()(D:\ Programy \ WebServ \ httpd \ fitspace \ modules \ locale \ locale.module的第403行)中獲取非對象的屬性。

我現在可以看到某種形式的評論,但並不完整。我可以看到主題字段,保存按鈕和我的名字