Sie sind nicht angemeldet.

Lieber Besucher, herzlich willkommen bei: krpano.com Forum. Falls dies Ihr erster Besuch auf dieser Seite ist, lesen Sie sich bitte die Hilfe durch. Dort wird Ihnen die Bedienung dieser Seite näher erläutert. Darüber hinaus sollten Sie sich registrieren, um alle Funktionen dieser Seite nutzen zu können. Benutzen Sie das Registrierungsformular, um sich zu registrieren oder informieren Sie sich ausführlich über den Registrierungsvorgang. Falls Sie sich bereits zu einem früheren Zeitpunkt registriert haben, können Sie sich hier anmelden.

1

Dienstag, 17. September 2013, 22:36

Variable not passing correctly, [object Object]

I'm attempting to dynamically add the ability to load a specific scene by passing a variable through the URL. (E.G. http://domain.com/tour.php?scene=1) Everything seems to be working fine up until I try to have the xml file parse the variable; it returns "[object Object]" instead of the value I'm passing.

Here's the pertinent code:
PHP

Quellcode

1
2
3
4
5
6
// Grab the variable from the URL. If not present, default to scene 0
if (isset($_GET['scene']))	{
	$loadScene = $_GET['scene'];	
} else {
	$loadScene = "0";	
}



to Javascript

Quellcode

1
2
3
4
// Create Viewer
var viewer = createPanoViewer({swf:"virtualtour.swf", xml:"virtualtour.xml", target:"panoDIV"});
viewer.addVariable("scene", '<?php echo $loadScene; ?>');
viewer.embed();



to virtualtour.xml

Quellcode

1
<include url="virtualtour%$scene%.xml"/>



results in "FATAL ERROR: virtualtour[object Object].xml - loading failed! (404)" ... which makes sense because, well, that file doesn't exist. *tongue*

Any ideas why the variable doesn't pass through correctly? Thanks!

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Mittwoch, 18. September 2013, 00:49

pretty sure you can't use variables in the include part.

Have your xml be a php and pass a php variable so that it works that way.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

3

Mittwoch, 18. September 2013, 01:40

Thanks for the reply!

I've seen posts where people pass variables into the include, most commonly as a cache buster. Perhaps I'm missing a step somewhere?

That method would work, but unfortunately not in my case. It would require a HUGE overhaul/rewrite for my client and that's just not currently feasible.

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

4

Mittwoch, 18. September 2013, 02:26

Normally, your scenes should be your main xml. And everything else is your include.
Since your index is php, its easy to point to your different xml right there.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

5

Mittwoch, 18. September 2013, 03:15

The way it's been set up, the chrome and scenes are in a separate xml files. They've been using PanotourPro for a while now with a lot of tours already built. I'm trying to extend functionality further (gonna need to insert code manually into some existing tours, then use my injection points with PanotourPro's theming to have this built-in moving forward). They work like this:

index.php -- loads the main virtualtour.xml file
virtualtour.xml -- contains the stage and all the UI chrome. This also loads the first scene, virtualtour0.xml, by default via include
virtualtour#.xml -- any number of individual scenes, loaded dynamically through hotspots or a combo box

The client is looking for a way to take a multi-scene tour and be able to specify a starting point by passing that through a variable in the URL. So, for example, if they want to embed or link a tour and start with a specific scene, the could pass that with a URL structured like http://domain.com/tour.php?scene=1

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

6

Mittwoch, 18. September 2013, 07:05

That's fine.
Just do it differently. That way you can setup your php in the index file and pass it directly to your customized xml. Very simple.

index.php -- loads the individual scene xml files.
virtualtour#.xml -- any number of individual scenes, loaded dynamically through hotspots or a combo box. Before the start of the scene tags includes virtualtour.xml and startup action to load first scene if no scene specified.
virtualtour.xml -- contains the stage and all the UI chrome.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

7

Mittwoch, 18. September 2013, 08:14

Hi,
I'm attempting to dynamically add the ability to load a specific scene by passing a variable through the URL. (E.G. http://domain.com/tour.php?scene=1) Everything seems to be working fine up until I try to have the xml file parse the variable; it returns "[object Object]" instead of the value I'm passing.
The name 'scene' can't be used for a variable because that's already a predefined array (the array of <scene> elements in the xml).
Just use an other name for your variable and it should work.

Best regards,
Klaus

8

Mittwoch, 18. September 2013, 19:28

Ha! I totally didn't even consider that. Thanks!

9

Freitag, 20. September 2013, 19:57

Well, I finally got around to trying that and it didn't work. I renamed the variable in the php and javascript to "asdf" and made the appropriate change in the xml file. Now I'm getting a Loading Failed (400) error. Any ideas?

10

Freitag, 20. September 2013, 20:05

More information on how I've got things set up: I'm currently running this on my dev machine with MAMP using a virtualhost, browsing with Safari in HTML5. When browsing in Chrome with Flash, I get a Loading Error (IO Error).

11

Freitag, 20. September 2013, 20:24

Update: I added passQueryParameters to my javascript.

Quellcode

1
2
3
4
var viewer = createPanoViewer({swf:"virtualtour.swf", xml:"virtualtour.xml", target:"panoDIV"});
viewer.addParam(passQueryParameters, true);
viewer.addVariable("asdf", '<?php echo $loadScene; ?>');
viewer.embed();


That looks like it's starting to do the trick. When loading the page, the pano doesn't load—I just get a white viewport—but viewing the source shows the viewer div and the appropriate embed content.

12

Freitag, 20. September 2013, 21:57

Additional note: when I pull up the error console in Safari, I get the following:

Zitat

ReferenceError: Can't find variable: passQueryParameters

13

Dienstag, 24. September 2013, 22:57

Well, having spent some time away from this, came to realize I was sending query parameters incorrectly. Changed that line to

Quellcode

1
viewer.passQueryParameters();


and still getting a Loading Failed (400) error.

Here's the revised code again in case anyone has any ideas

PHP

Quellcode

1
2
3
4
5
if (isset($_GET['VMScene']))	{
	$loadVMScene = $_GET['VMScene'];
	} else {
	$loadVMScene = "0";
	}


Javascript

Quellcode

1
2
3
4
var viewer = createPanoViewer({swf:"virtualtour.swf", xml:"virtualtour.xml", target:"panoDIV"});
viewer.passQueryParameters();
viewer.addVariable("VMScene", <?php echo $loadVMScene; ?>);
viewer.embed();


xml

Quellcode

1
<include url="virtualtour%$VMScene%.xml"/>

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

14

Mittwoch, 25. September 2013, 05:35

Try

viewer.addVariable("VMScene", "<?php echo $loadVMScene; ?>");
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

15

Mittwoch, 25. September 2013, 23:13

No luck, it gives me the same Loading Failed (400) error. :-/

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

16

Donnerstag, 26. September 2013, 04:45

I used your exact syntax and it worked.

passquery parameters is not needed if your are embedding the variables in that way. That's needed if you have them in the url and aren't using php to use addvariable.

Check the javascript console to see if the file is being called right or you have a bad path directory or something else.

I didn't even know this type of variable/placeholder was possible. I must have missed it in the documentation. Where is it exactly?

http://www.seeit360.com/w8/?VMScene=2

Quellcode

1
2
3
4
5
6
7
	<?php
	if (isset($_GET['VMScene']))	{
	$loadVMScene = $_GET['VMScene'];
	} else {
	$loadVMScene = "0";
	} ?>
	viewer.addVariable("VMScene", <?php echo $loadVMScene; ?>);


http://www.seeit360.com/w8/?VMScene=2
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

17

Freitag, 27. September 2013, 00:42

Huh. Well, now that I know it works, I just need to sort out where the disconnect is happening on my end. I pushed my code onto my server (instead of just testing on my localhost) and I'm still getting the same error. Thanks for taking the time to give it a go. I guess at this point I need to strip my code down to bare minimum to see where it fails.

I found it in the XML reference document: http://www.krpano.com/docu/xml/#url-notes

18

Freitag, 27. September 2013, 01:32

And is this how you're including the file(s)?

Quellcode

1
<include url="virtualtour%$VMScene%.xml"/>


I'm about to pull my hair. Haha! It just seems as though krpano isn't parsing the variable placeholder correctly in the xml for some reason.

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

19

Freitag, 27. September 2013, 04:03

Exactly like that.
Try to use chromes developer tools. It maybe just a path issue. Or post a link to your project or PM it to me.
Could be your krpano is older than that feature.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

20

Donnerstag, 31. Oktober 2013, 21:22

After some time away—had to work on other things—I made sure the viewer was up-to-date... still no dice.

I'll post a link online and send you the test project and PM it to you in the next couple days, if you can still take a look at it. Thanks!