print commentform AFTER a (while next_image) loop on image.php

I have a (while next_image) loop on my image.php page to display all images in the album at once.
(the page is called with getFirstImageURL() )

after the while loop is done i place a commentform on this page. But i noticed that there is something going wrong with the printCommentForm()

the commentform ofcourse only posts a comment for the first image. the posting works ok, BUT the part of the function that displays the already posted comments shows "no comments". ( the context is set to another image by the while-loop??)

how do i set the context back to the first image before printing the commentform?

i could also use $_zp_current_image->getComments() and print the whole array separately but i would prefer the standard function inside the printcommentform() function since this is already fully styled.

Comments

  • acrylian Administrator, Developer
    What are you actually doing or want to do? The next_image loop sets the current image object of course for each image in that loop one after another.

    You can of course set the $_zp_current_image again to the object of the first image manually. See the object model tutorial.

    If you want to show thumbs for navigation I suggest to use one of the plugins for this purpose: pagethumbsnav or jcarousel. That saves you all this hassle actually.
  • in the end i want to display the posted comments separate from the form itself. right now i use part of the printCommentForm() function to display the comments:

    `

    <?php while (next_comment())<br />
    {

    ?>



    ">

    <?php printCommentAuthorLink();?>

    : on <?php echo getCommentDateTime(); printEditCommentLink('Edit', ', ', ''); ?>



    <?php echo getCommentBody();?>



    <?php } ?>

    `

    if i place printCommentForm() BEFORE the while-loop everything is ok. but due to my design it has to be placed after it...and thus the function doesnt work correctly anymore.

    i dont see how to make 'while (next_comment())' ,in the code above, loop through the first image comments in the tutorial you mention.
  • You will have to preserve and then restore the context around the `next_image()` loop. It is not normal to have an "album" functionality on the image page, so to accomplish that you will have to remove the damage it has done.
Sign In or Register to comment.