0
votes

I am trying to build a gallery similar to Facebook. This is what I was able to do for now:

1) I created content type album with title and description fields.

2) Then I created content type photos, with field picture and field album name, referencing node created in (1)

3) Then I added some example content. Let's say I created album A and B, as well as photos 1, 2, 3 and 4 referencing album A and photos 5, 6, 7 and 8 referencing album B.

4) I created a view which shows all albums created by particular user, showing thumbnail photos per album as well. In my case it looks like this:

Album A name: photos 1, 2, 3, 4

Album B name: photos 5, 6, 7, 8

So far so good, I have problem with the very next one.

5) I want to create override for each album Node using views and I want to show all photos per given album, with pager showing only 1 photo at once. This was not problematic, I need only one last thing, a comment form with all comments per each photo (not the album). So I have pager 1 to 8 and if I go from photo 1 to 2, I want the comment form to change so that it belongs to photo 2 now.

I tried theming the view, Row style output part of it, I tried to use comment_form and array('nid' => $nid) but I get many errors with that method, for example

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).

I searched over the internet to find solution but without success, so you are my last hope.

2

2 Answers

0
votes

comment_form() is expecting the $comment parameter to be an object and you're passing array.

Try

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

I tried this:

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

Getting for example following messages:

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 comment_form() (line 1878 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). Notice: Trying to get property of non-object in comment_form() (line 2009 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). Notice: Trying to get property of non-object in comment_form() (line 2023 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). Notice: Trying to get property of non-object in comment_form() (line 2031 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). Notice: Trying to get property of non-object in comment_form() (line 2037 of D:\Programy\WebServ\httpd\fitspace\modules\comment\comment.module). Notice: Trying to get property of non-object in comment_form() (line 2043 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).

I can see some kind of form comment now, but not complete one. I can see Subject field, save button and my name