Gallery not going back correctly from link [[+galitem.albums]]

Link should go back to gallery from galleryItem, but uses id of current page.
This is the link address

 https://www.wemyssweb.net/index.php?id=16&galAlbum=3

This is the correct link

https://www.wemyssweb.net/index.php?id=17&galAlbum=3

I tried this in a custom chunk

 <span><a  [[+total:lt=`7`:then=`
     href="[[~13? &[[+albumRequestVar]]=`[[+id]]`]]"
     `:else=`
     href="[[~17? &[[+albumRequestVar]]=`[[+id]]`]]" 
   `]]>[[+name]]</a></span>

<a

This does not work correctly because it does not know how many images in the album.
Unless ther is a way to pass that information to the image item page?
If nobody can give me an answer, I will have to use a backlink.

<button onclick="history.back()">Go Back</button>

Maybe you can pass this information with an additional request-parameter:

[[!Gallery?
	&thumbTpl=`myGallery`
	...
]]
<!-- In then chunk "myGallery" -->
<a href="[[~16?
	&[[+imageGetParam]]=`[[+id]]`
	&[[+albumRequestVar]]=`[[+album]]`
	&total=`[[+total]]` ]]">
<!-- or maybe like this -->
<a href="[[~16?
	&[[+imageGetParam]]=`[[+id]]`
	&[[+albumRequestVar]]=`[[+album]]`
	&returnId=`[[*id]]` ]]">

Tried both examples , they add parameters to the url, but not the link to the Album.
If I could change the first part [[*id]]?

<span><a href="[[~[[*id]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+name]]</a></span>
https://www.wemyssweb.net/index.php?id=16&galAlbum=3

It is ok if I am on the same page.

On the “Gallery Item” page, you then have to read this additional request parameter to generate the correct link back to the Gallery.

You can either read the value of a GET request parameter with the FastField syntax (if pdoTools is installed)

[[#GET.returnId]]

or you can use an extra like getUrlParam or a custom snippet.

Is this correct?

[[!Gallery?
    &thumbTpl=`myGalItemThumb`

My myGalItemThumb chunk

<figure>
<picture>
    <a href="[[~16?
        &[[+imageGetParam]]=`[[+id]]`
        &[[+albumRequestVar]]=`[[+album]]`
        &[[+tagRequestVar]]=`[[+tag]]`
        &returnId=`[[*id]]`
        ]]">
    <img src="[[+thumbnail]]" alt="[[+description]]" />
    </a>
</picture>
<figcaption>[[+description]]</figcaption>

GalleryItem snippet

[[!GalleryItem?
  &albumTpl=`myGalItemAlbum`
  ]]  
   <button onclick="history.back()">Go Back</button> 
Albums: [[+galitem.albums]]
[[!+galitem.image:notempty=`<img src="[[+galitem.image]]" alt="[[+galitem.description]]" />`]]

My myGalItemAlbum chunk

<span><a href="[[~[[#GET.returnId]]? &[[+albumRequestVar]]=`[[+id]]`]]">[[+name]]</a></span>

This worked thanks.
But I might use a backlink because each image belongs to 1 album.
Maybe I am approaching a solution the wrong way.
Just wanted it easy for the client just to create an album and that’s it.

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.