Problems, need help? Have a tip or advice? Post it here.
6 posts Page 1 of 1
Hi y'all

I'm building a gallery and want to be able have a 'next image' button. For that purpose I would need to be able to get the ID of the following page/image. How do I get that?

I have the idea to just get the current ID by using the k_page_id variable and then adding 1 to it. This could work, but I would never be able to delete an image or have it moved in the folder I think. So it would be better to can access the ID or Name of the next element
Hi,

I think you should find the following thread useful -
viewtopic.php?f=8&t=7087
Thank you, but this doesn't quite help me since I do not display a single page.

My code looks like this:

Code: Select all
<cms:pages masterpage="gallery.php" include_subfolders='0'>
      <div class="cssbox">
        <a id="<cms:show k_page_id />" href="#<cms:show k_page_id />">
          <img class="cssbox_thumb" src="<cms:show gg_thumb />">
          <span class="cssbox_full">
            <img src="<cms:show gg_image />">
          </span>
        </a>
        <a class="cssbox_prev" href="#<cms:add k_page_id '1' />">&#60;</a>
        <a class="cssbox_close" href="#void"></a>
        <a class="cssbox_next" href="#<cms:sub k_page_id '1' />">&gt;</a>
      </div>
</cms:pages>


I do only make the image by having the element targeted in the URL. My current approach to the next & previous button can be seen as well, but I already talked about the problem with this solution.
Does no one knows the answer?

I would be really thankful for some help
I think you are using JS (probably some kind of a slideshow) to loop through the pages.
For this, you don't actually require to know the 'k_page_id's - any kind of unique ID you choose to give should be sufficient for JS.

One way would be to use the 'k_count' variable.
It is very bold and ridiculous to assume no one here knows an answer. Perhaps, you were given time to assess, realize and correct your mistakes?

Uttering 'your cars don't drive' while standing in front of a car dealership unless they give you one to ride? Given the history of this forum free support, it is at least not respectful.

Your were wrong in the first place to have k_page_id as an image's identificator. Instead, it is expected by the CSSBox itself that identificators are continuos and not random numbers. As you might guess, deleting a page in backend does not reassign new ids to the other pages in order to avoid a hole in the numbering. So, ids can go like 1, 3, 4, 10, 15 and are unique and permanent. A valid approach is to use k_current_record or, simply, k_count to have numbers uniquely and continuously increase, allowing to employ <cms:add> and <cms:sub> tags. To create a loop, you'd need to assign the first image's prev to the last image's number and for the last image's next - first image's number, respectfully. Variables wil help and are there if you need them - see for yourself by placing <cms:dump> inside the loop.
6 posts Page 1 of 1