ZenphotoCMS Forum
Index shows first image of first album - 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: Index shows first image of first album (/thread-1477.html)



Index shows first image of first album - genial - 2007-06-10

Is it possible to call the first image of the first album directly into index.php? Currently I have to click through the link for an album, and then choose an image in order to see anything. That's a few more steps than I'd like. Ideally when the link to the zenphoto site is clicked the code would serve the first image up. I've already built the links to the other albums and the thumbnails for the current album into image.php so there's a way back. I'd rather not have to hard-code the link to the first image since this is for a client and it's quite possible that link would have to change regularly. Perhaps something like the "set context" call but for the first album of the set?




Index shows first image of first album - thisisted - 2007-11-19

[b] Is it possible to call the first image of the first album directly into index.php? Currently I have to click through the link for an album, and then choose an image in order to see anything. That's a few more steps than I'd like.
[/b]
I would also like to have this feature. Does anyone know how to get this to work?




Index shows first image of first album - sbillard - 2007-11-20

try:

`global $_zp_gallery;

$alb = $_zp_gallery->getAlbums(0);

$first = $alb[0];

$firstAlbum = new Album($_zp_gallery, $first);

$img = $firstAlbum->getImages(0);

$first = $img[0];

$firstImage = new Image($firstAlbum, $first);`




Index shows first image of first album - thisisted - 2007-11-20

Sorry, I'm new with php. Where do I put the code?




Index shows first image of first album - sbillard - 2007-11-20

You will have to put it in your index.php page where you want the link to the new image. However, this code only gets you the object for the new image. You will need to do more to show the link/thumbnail, whatever you wish.




Index shows first image of first album - thisisted - 2007-11-20

Sorry but I must have misinterpreted Genial's request. I guess my question is different.

What I would like to have is the normal index page that lists albums with thumbnails, but instead of showing the album view when a user clicks on a thumbnail from the index page, I would like it to link to the album's first image. Is there a way I could sidestep the album view page?




Index shows first image of first album - sbillard - 2007-11-20

You can use the code above to get an object of the first image in an album. Then change the call on getAlbumLinkURL() to $firstImage->getImageLink();




Index shows first image of first album - thisisted - 2007-11-21

I'm extremely new to this.
Where on the album.php page should I paste the above code?
Here's my album.php page:
`




Index shows first image of first album - sbillard - 2007-11-22

That really depends on where you want the thumbnail to appear on the page.

A quick tour of the code above:
the gallerytitle div is where the name and link back to the gallery page is done.

the images is where your image thumbnails are generated.

Note: this theme would not support subalbums. If you are really new to all this I suggest you take one of the existing themes--say the example theme (which is called testing in the 1.1.2 release) as a starting point.

It is index.php which shows the first level albums. Second level albums (subalbums) are normally shown by the album.php page. However what you have above does not do them.




Index shows first image of first album - thisisted - 2007-11-22

Thank you for the info about subalbums. I do not plan on using subalbums on my site so updating is not necessary.
I have tried replacing the images div with your code on my album page, but I get a fatal error from the $img = $album->getImages(0); line.

Where on the album.php should I add your code?

Perhaps it would be easier for the album link on the index.php page to link straight to the first image of the album. Would this be possible?




Index shows first image of first album - sbillard - 2007-11-22

You should read more carefully. If you don't plan to have subalbums, then there will NEVER be an album on the albums page, just the thumbnails for the images in the album. So, it is kind of pointless to put the code in the album.php file.




Index shows first image of first album - thisisted - 2007-11-22

I have tried placing your code on my album.php page and then on my index.php page, and both return the following error:

[b]Fatal error: Call to a member function getImages()
[/b]
Is this a new function for ZenPhoto 1.1.2, or should I put the code somewhere else?




Index shows first image of first album - sbillard - 2007-11-23

getImages is defined in class-album.php. It has been there forever. However, if you are not using the 1.1.2 release, please do. We cannot help you if you are not on current software.

You do, of course, have to have a valid album object to use the function.




Index shows first image of first album - sbillard - 2007-11-23

I have edited the code above to correctly use $firstAlbum. Please be sure that you take example code with a grain of salt. Obviously I have not implemented this function. I am trying to give you examples of how to do something. However, it is not final polished code and is created on the spur of the moment. You need to be able to understand what is attempted and make modifications as needed to make the code correct. If this is too much for you, then perhaps you should not be taking on this project.




Index shows first image of first album - thisisted - 2007-11-24

I got it to work kind of!
I upgraded to 1.1.2, put your new code on index.php and changed getAlbumLinkURL() to $firstImage->getImageLink();.
It does work, except now all of the thumbnails on the index page point to the first photo of the first album. I played around a little and noticed that if I change the number from 0 to 1 in the $first = $alb[0]; line, the thumbnails would then link to the first image of the second album.

Is there a way for each of the albums on index.php to have their own link be first image of their album?

Here's my index.php file:

`




Index shows first image of first album - thisisted - 2007-11-30

Anyone willing to help?




Index shows first image of first album - Filip - 2009-02-18

Sorry for raising a dead topic but I'm trying to acomplish the same thing. But the index.php is different now and I don't know how to solve my problem.

I tried to change
`




Index shows first image of first album - Filip - 2009-02-22

I still haven't solved my problem. I read the "Skipping (sub) album view" threat but that didn't help me.