Member
Member
genial   10-06-2007, 01:06
#1

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?

Member
Member
thisisted   19-11-2007, 23:56
#2

[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?

Member
Member
sbillard   20-11-2007, 02:13
#3

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);`

Member
Member
thisisted   20-11-2007, 09:10
#4

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

Member
Member
sbillard   20-11-2007, 18:07
#5

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.

Member
Member
thisisted   20-11-2007, 18:59
#6

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?

Member
Member
sbillard   20-11-2007, 23:30
#7

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();

Member
Member
thisisted   21-11-2007, 21:19
#8

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

Member
Member
sbillard   22-11-2007, 04:13
#9

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.

Member
Member
thisisted   22-11-2007, 07:01
#10

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?

Member
Member
sbillard   22-11-2007, 17:08
#11

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.

Member
Member
thisisted   22-11-2007, 22:43
#12

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?

Member
Member
sbillard   23-11-2007, 00:13
#13

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.

Member
Member
sbillard   23-11-2007, 00:19
#14

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.

Member
Member
thisisted   24-11-2007, 08:35
#15

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:

`

Member
Member
thisisted   30-11-2007, 05:15
#16

Anyone willing to help?

Member
Member
Filip   18-02-2009, 17:07
#17

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
`

Member
Member
Filip   22-02-2009, 19:21
#18

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

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.