ZenphotoCMS Forum
which $item with printLatestComment function for current image - Printable Version

+- ZenphotoCMS Forum (https://forum.zenphoto.org)
+-- Forum: Support (https://forum.zenphoto.org/forum-1.html)
+--- Forum: General support (https://forum.zenphoto.org/forum-4.html)
+--- Thread: which $item with printLatestComment function for current image (/thread-13661.html)



which $item with printLatestComment function for current image - pled - 2021-11-01

Hi,
Sorry for the noob question, but I have no dev skills...
I am customizing zenji theme, and try to display latest comment for the current image in the side bar, so within image.php file (I expect comments for that image only, same as with the printComment Form() does).

I've seen the printLatestComments() function, and the $item parameter ("the record id of element to get the comments for") required when using 'image' as $type for that function.
But I cannot find what is needed as $item value in my case.

I tried the following :

But then nothing is returned. When using :

I can get latests comments from the gallery, so the function works.

Any help woud lbe welcome !
Thank you.




which $item with printLatestComment function for current image - acrylian - 2021-11-01

You nearly got it. The id refers to the id of item in the database, you get this via $_zp_current_image->getID().

But if you use comments, the comments would be listed below the comment form anyway so you would double them, wouldn't you?




which $item with printLatestComment function for current image - pled - 2021-11-01

Thanks, it works !

Yes, latest comments would be duplicated... unless I use the printCommontForm function, setting the $displaycomments to false :

Then only the "add a comment" section is displayed at the bottom. Perfect !

Ideally, I would like to display all comments in the sidebar (there are generally few comments for a specific image in my gallery, so it should size here well) ; but I guess the printCommentForm allows to only display comments ? This is why I am using printLastestComments in the side bar, and using a bigger $number should do the trick !




which $item with printLatestComment function for current image - pled - 2021-11-01

Sorry I meant printCommentForm() does not allow to display only comments (ie the add new comment section is included).




which $item with printLatestComment function for current image - acrylian - 2021-11-01

printCommentForm() does not make much sense if you disable the form, does it. But you already found how to disable the comments listing.

There are numerous way to display comments instead of using printLatestComments(). You could use the object model directly (the base level if you will with full control over the output). Or you can use the next_comment loop on an image page (or any other item type like an album, Zenpage page or article) to show all of its comments. You can see it's usage within printCommentForm() around line 340.




which $item with printLatestComment function for current image - pled - 2021-11-13

Right, the [code]next_comment[/code] loop is more appropriate for my purpose, and probably easier to use for me compared to object model ! I will use it.
Thank you for your kind help.