Member
Member
LondonLight.org   2014-06-28, 15:00
#1

Hey!

I'm almost done writing a new ZenPhoto theme tailored to showing HTML5 and Flash virtual panoramas. One last thing I need to get working is panorama hotspots. When I open a pano from the album-pano.php page everything works fine - the image-pano.php page is loaded, the title and description of the "image" are shown and the panorama plays in the . Javascript from Pano2VR targets the #container and puts the panorama there.
http://i.imgur.com/69My6oz.jpg

The problem is that when a user clicks on the door hotspot to go to the next panorama, that is handled by the javascript from Pano2VR which then replaces the contents of #container with the new pano. That's no good, because the name and description of the pano on my page outside of #container remains from the previous one.

I want to use hotspot urls relative to the current image (the whole tour resides in one album) so that I can then rename the album and parent albums without worrying about breaking links, otherwise if I use absolute URLs I'm in for a lot of work if I want to rename a parent album, I'd have to edit every pano's XML file which contains the hotspot URLs.

I think I solved the problem, unfortunately when a user clicks on the door, instead of getting taken to
http://127.0.0.1/zp/Panoramas/House%20of%20Karin/Foyer.txt
which works, they get taken to
http://127.0.0.1/zp/albums/Panoramas/House%20of%20Karin/Foyer.txt
which does not work, because of the "albums".

Even though the URL in the web browser is
http://127.0.0.1/zp/Panoramas/House%20of%20Karin/Porch.txt
(notice no "albums"), getUnprotectedImageURL() indeed shows
/zp/albums/Panoramas/House of Karin/Porch.txt
(with "albums") for this working URL, and getImageURL() shows
/zp/Panoramas/House%20of%20Karin/Porch.txt
I guess the .htaccess file does some magic here.

When a user clicks on a hotspot, the browser URL shows
http://127.0.0.1/zp/albums/Panoramas/House%20of%20Karin/Foyer.txt
with "albums", and that shows the contents of the txt file instead of loading the Foyer panorama.
If I remove the "albums/" part from that URL in the browser, it works and shows the pano, not the contents of Foyer.txt

Please help getting htaccess to remove "albums/" from the URL if it contains it.

/zp/.htaccess
`

htaccess file version 1.4.5;


Rewrite rules are now handled by PHP code


See the file "zenphoto-rewrite.txt" for the actual rules



These rules redirect everything not directly accessing a file to the Zenphoto index.php script



    IndexIgnore *

RewriteEngine On

RewriteBase /zp

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [L]

RewriteRule ^.*/?$ index.php [L,QSA]

`

Administrator
Administrator
acrylian   2014-06-28, 15:19
#2

http://127.0.0.1/zp/albums/Panoramas/House%20of%20Karin/Foyer.txt is the correct full image url which getUnprotectedImageURL() gets. Just that here the "image" is a "text-object" so the full image is the txt-file.

What you are looking for is the image.php page url. No need for htaccess modifcation should be needed.

You get that via getImageURL() if you are in image context, for example withon the next_image() loop. Example of that is in every standard themes' album.php page. Or via the object model $image->getLink() where $image is an image object naturally.

Member
Member
LondonLight.org   2014-06-28, 19:29
#3

Here's a cleaner explanation (because now I understand the problem better):

Folder structure:
http://i.imgur.com/645iT2J.png

I use Pano2VR to display the pano in a div with id #container. The Pano2VR player is written in javascript, and uses XML files to store each panorama's configuration. The XML file must have an XML extension.
`

pano.readConfigUrl("");

Now I simplified the process of getting $panoXML:
$txtFile = pathinfo(getUnprotectedImageURL());
$panoXML = $txtFile ['dirname'] . '/tour/' . stripSuffix($txtFile ['filename']) . '.xml'; ?>
`
so $panoXML returns:
/zp/albums/Panoramas/House of Karin/tour/Foyer.xml
It does not work when I remove "albums/" from that path.

For reference:
getImageURL: /zp/Panoramas/House%20of%20Karin/Foyer.txt
getUnprotectedImageURL: /zp/albums/Panoramas/House of Karin/Foyer.txt

Clicking on any image thumbnail from my album-pano.php page loads the panorama in the image-pano.php page correctly.
album-pano.php: http://i.imgur.com/hzVQsoC.jpg
image-pano.php: http://i.imgur.com/EtNGvQn.jpg
All good.

The problem are the hotspots. If I use
`

Administrator
Administrator
acrylian   2014-06-28, 19:56
#4

You really don't need to use htaccess. That will have side effects, the actual rewrite handling is not done via that at all but internally.

domain.com/albums// -> full image in the album
domain.com// -> image page of the image of the album

You request the full image so that gets you the txt file on text objects correctly. If you wish to link hotspot to further panoramas based on text objects you need to link to the image page instead the item itself. I hope I understood the issue correctly.

You probably have to use the object model directly as within your scripts the right context are not set for normal template functions. Of course since Zenphoto is file system based any renaming of albums or images will require changes afterwards. The names are also the base for the object model.

I hope that helps for now.

Member
Member
LondonLight.org   2014-06-28, 20:26
#5

Acrylian thank you for taking the time to read through this and answer

I think I understand you, and I think you understood the issue correctly.

Quote:If you wish to link hotspot to further panoramas based on text objects you need to link to the image page instead the item itself. I hope I understood the issue correctly.
Question is, is it possible to do that without using absolute paths?
"You have to use the object model directly" I'm not clear on this, could you give a link or example to show what you mean?

Knowing that if I set the hotspot URL to just foo, and that clicking it will result in the URL being http://127.0.0.1/zp/albums/Panoramas/House%20of%20Karin/tour/foo, and that the same URL without albums/ would work and save me a lot of time in the future if I rename the parent album, is there anything I could do to keep this independent relative structure?

Administrator
Administrator
acrylian   2014-06-28, 21:03
#6

I can only cite my post from above:

Quote:What you are looking for is the image.php page url. No need for htaccess modifcation should be needed.

You get that via getImageURL() if you are in image context, for example withon the next_image() loop. Example of that is in every standard themes' album.php page. Or via the object model $image->getLink() where $image is an image object naturally.
You should always use these functions as that way you cover possible changes on Zenphoto updates.

Also take a look:
http://www.zenphoto.org/news/zenphotos-object-model-framework
http://www.zenphoto.org/news/zenphotos-global-variables

Member
Member
LondonLight.org   2014-06-28, 22:50
#7

I read those pages several times already. I don't follow how any of that helps if I'm clicking on a link which gets handled by proprietary obfuscated javascript, not by ZenPhoto, and the link should be relative to nothing more than its containing album. The result of the click is this URL
http://host/zp/albums/Panoramas/Album/image.txt
That's all I get to work with.

I got the hotspots working correctly using /zp/.htaccess
RewriteRule ^albums/(.*)\.txt $1.txt [NC,R,L]
It fulfills my needs and I can rename parent albums of the album containing the individual panorama "images" without having to edit any code.

Administrator
Administrator
acrylian   2014-06-29, 07:37
#8

Maybe I then did not understand the problem exactly.So you are talking about links within the txt- file then? Those are indeed outside of the "knowledge" of Zenphoto scope then. You can either use absolute or relative paths to achieve it probably. A proper site link example might have helped. But anyway whatever works for you :-)

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