Pages (2): 1 2   
Member
Member
nbruley   09-12-2010, 06:56
#1

I would like to be able to add a document link under thumbnails if there is a matching name with a different extension. For instance, if there is both a "myphoto.jpg" and a "myphoto.pdf" I would like a hyperlink to appear under the thumbnail of "myphoto.jpg" that links to the pdf version of the file. I don't really know php but I made a guess as to what the code might look like. Can someone help me out with this? Thank you! (The main problem is figuring out how to ask if the particular file exists. I can't get even a hard-coded url to work.)

    

Member
Member
Member
nbruley   09-12-2010, 17:08
#3

Looks like there is a basename(path,suffix) function that would maybe work better than the substring function...

Member
Member
nbruley   09-12-2010, 17:21
#4

Another try that is probably just as bad...

`

`

Member
Member
sbillard   09-12-2010, 18:29
#5

You do not want to be using WEB links since the file will actually be on the server. What you need is $image->localpath() to get the filesystem path to the image file.

Member
Member
nbruley   09-12-2010, 21:50
#6

ah, I see. I will try that. Thanks much!

Member
Member
nbruley   09-12-2010, 22:07
#7

I tried
``
in album.php just to see what it returned and got an error.
http://www.test-gallery.mysitecreations.com/bookmarks/English/
I don't think I know enough about zenphoto or coding to do this.... if I'm missing something obvious I'd be glad to know.

Thanks.

Member
Member
sbillard   09-12-2010, 22:49
#8

$image is a standin for whatever image you are interested in. In your case I suspect it should be $_zp_current_image, presuming you are useing it within the next_image() loop.

Not sure what $image was for you, probably undefined.

Member
Member
nbruley   26-01-2011, 00:19
#9

Well, I'm back on this as I think this would best suit my needs, if you don't mind...
does not work but
does.

I get the error
Fatal error: Call to undefined method _Image::localpath() in /home6/mysitecr/public_html/test-gallery/themes/effervescence-nb/album.php on line 292

I think I'm within the image loop because the folder name is repeated for each thumb, and it is located immediately after the printImageThumb command. I don't know php (beyond a few tutorials in w3schools, although I'm javaScript certified) so maybe this is something simple I'm overlooking?

Thanks for your patience.

I'm working with the test site at
http://test-gallery.gospelriver.com/bookmarks/English/

Member
Member
kagutsuchi   26-01-2011, 01:13
#10

localpath is a property, not a method, so it should actually be $_zp_current_image->localpath instead. http://www.zenphoto.org/documentation/classes/_Image.html#var$localpath

Member
Member
nbruley   26-01-2011, 02:32
#11

Success!!! Thank you!

Member
Member
nbruley   26-01-2011, 04:16
#12

Ok, I'm making good progress now. Is there a cheat sheet on all the menthods and classes I would need to reference the actual file location?

This is what I have so far. The if statement works, but I have the file location hard-coded because I don't know the best way to get that.

Also, I don't think getBareImageTitle() is what I want-- I want the file name, not the title I give it in Zenphoto.

`

Member
Member
nbruley   26-01-2011, 04:28
#13

Edit: I got the bookmarks to flow by adding in some line breaks... probably not the "right" thing to do but seems to work...

Edit2: Page 4 doesn't work with line breaks either... any ideas?
http://test-gallery.gospelriver.com/bookmarks/English/page/4/

Maybe the best thing to do would be to just create a link on the image page...?

Administrator
Administrator
acrylian   26-01-2011, 10:52
#14

You get the filename by using $_zp_current_image->filename. Your other problem with the line breaks, I don't understand actually.

Member
Member
nbruley   26-01-2011, 13:41
#15

Thanks acrylian for the tip-- this almost works for me.
The problem with using $_zp_current_image->filename is that it gives me
http://test-gallery.gospelriver.com/bookmarks/English/apple-delight.pdf
instead of
http://test-gallery.gospelriver.com/albums/bookmarks/English/apple-delight.pdf
and thus gives me a broken link. I need the location of the actual file, since I am referencing the matching pdf of the jpg, which is in the albums folder. Zenphoto skips over the albums folder for some reason when making its links. If I had to, I could do a replace like "gospelriver.com/" with "gospelriver.com/albums/" but then I would have to hardcode this for all my sites.

Regarding the line breaks- I took them out. Check my site and see if you see a problem with the formatting. I need a way to make the bookmarks wrap under the other bookmarks on the next line, not wrap only to the pdf link.

http://test-gallery.gospelriver.com/bookmarks/English/

Administrator
Administrator
acrylian   26-01-2011, 13:57
#16

$_zp_current_image->filename itself gives you only the filename, no path. For the full image there is getFullImageLinkURL(). See the documentation.

No, Zenphoto does not skip the "albums" folder. The albums folder is not used in normal page links therefore it is not included.

You can create a link to a file manually using:
getAlbumFolder().$_zp_current_album->name."/".$_zp_current_image->filename;
(you might need to add some slashes, quickly typed)

Member
Member
nbruley   26-01-2011, 15:06
#17

@acrylian:
getFullImageLinkURL() returned an undefined function error. I have tried getFullImageURL() before but it does not work for me because I cannot change the extension to .pdf and have the link still work. It does not recognize the pdf file I think because it is not indexed by zenphoto.

The problem with your second suggestion is it gives me the following:
http://test-gallery.gospelriver.com/home6/mysitecr/public_html/test-gallery/albums/bookmarks/English/apple-delight.pdf

the /home6/mysitecr/public_html/test-gallery is the link on the server and makes this link invalid- I don't know how to get a link without it...

Thanks for your help.

Administrator
Administrator
acrylian   26-01-2011, 15:39
#18

Well, I meant getFullImageURL() (always good to refer to the doc as I not always look there myself). Of course the pdf is not indexed if you did not make a plugin similar to the textobject one.

Ok, I got myself confused with "getAlbumsFolder()" - haven't used this in ages - as that means the folder of hte album, not the main albums folder. Use this:
FULLWEBPATH.'/'.ALBUMFOLDER.'/'.$_zp_current_album->name.'/'.$_zp_current_image->filename;

Member
Member
nbruley   26-01-2011, 16:18
#19

ah, perfect. Works great; Thanks much for this.

Finally found the documentation that addresses this... there's so much information to wade through, it's hard to find the function that works for you.
http://www.zenphoto.org/documentation/elementindex.html

I didn't find $_zp_current_album listed there though. Maybe that's because it is just a variable?

Did you have any input on how I can get the bookmarks to go all the way over to the left on the second line without stopping at the first "PDF" link?

Administrator
Administrator
acrylian   26-01-2011, 17:43
#20

Exactly, as it is a global variable and listed on its own article:
http://www.zenphoto.org/2008/07/zenphotos-global-variables/

To use it you have to look at the object model tutorial:
http://www.zenphoto.org/2010/02/zenphotos-object-model-framework/

Regarding your bookmarks, you will have to change the css a little to leave room for them. Look at the source code.

Pages (2): 1 2   
  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.