Sie sind nicht angemeldet.

1

Donnerstag, 12. Mai 2016, 16:34

Trouble getting KRpano to create XML via PHP

Hello everyone!

I having real trouble trying to get KRpano HTML5 viewer to work with dynamic XML from a MySQL database via PHP. I have a three-panorama tour, and the hotspots for each will be updated by the client in due course, so a dynamic system is required.

However... I've scoured the forums and documentation and although several threads (see below) suggest this is indeed possible, I've now spent two days trying to get it to work and have so far failed miserably :(

krpano HTML5 Viewer reading the database
Get KRPANO to read from a DATABASE
Integrate MySQL/PHP with Virtual Tour
Database conection question...

I have the tour.xml file, and here's a typical <scene></scene> tag:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<scene name="pano1" title="Panorama 1 - cases 1-9" onstart="" thumburl="panos/pano1/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="-30.363" vlookat="7.871" fovtype="MFOV" fov="70" maxpixelzoom="2.0" fovmin="70" fovmax="120" limitview="range" hlookatmin="-100" hlookatmax="100" vlookatmin="-60" vlookatmax="60" />

		<preview url="panos/pano1/preview.jpg" />

		<image type="CUBE" multires="true" tilesize="512">
			<level tiledimagewidth="3820" tiledimageheight="3820">
				<cube url="panos/pano1/%s/l4/%v/l4_%s_%v_%h.jpg" />
			</level>
			<level tiledimagewidth="1910" tiledimageheight="1910">
				<cube url="panos/pano1/%s/l3/%v/l3_%s_%v_%h.jpg" />
			</level>
			<level tiledimagewidth="956" tiledimageheight="956">
				<cube url="panos/pano1/%s/l2/%v/l2_%s_%v_%h.jpg" />
			</level>
			<level tiledimagewidth="512" tiledimageheight="512">
				<cube url="panos/pano1/%s/l1/%v/l1_%s_%v_%h.jpg" />
			</level>
			<mobile>
				<cube url="panos/pano1/mobile_%s.jpg" />
			</mobile>
		</image>

		<!-- HOTSPOT DEFINITIONS -->
		<hotspot name="pano2" style="skin_hotspotstyle" ath="-32.5" atv="15" linkedscene="pano2" />
		<hotspot name="case1" url="skin/infopoint.png" scale="0.7" ath="-52" atv="2" onhover="showtext(Case 1 - Introduction)" onclick="popup()" />
		<hotspot name="case2" url="skin/infopoint.png" scale="0.7" ath="-43.5" atv="3" onhover="showtext(Case 2 - Buzzbones)" onclick="popup()" />
		<hotspot name="case3" url="skin/infopoint.png" scale="0.7" ath="-41.2" atv="1" onhover="showtext(Case 3 - Sledge and Skate)" onclick="popup()" />
		<hotspot name="case4" url="skin/infopoint.png" scale="0.7" ath="-39" atv="-1" onhover="showtext(Case 4 - Handaxes)" onclick="popup()" />
		<hotspot name="case5" url="skin/infopoint.png" scale="0.7" ath="-91" atv="-2" onhover="showtext(Case 5 - Rattle)" onclick="popup()" />
		<hotspot name="case6" url="skin/infopoint.png" scale="0.7" ath="69" atv="0" onhover="showtext(Case 6 - Puppet/Doll)" onclick="popup()" />
		<hotspot name="case7" url="skin/infopoint.png" scale="0.7" ath="51" atv="4" onhover="showtext(Case 7 - Monumental Bronze)" onclick="popup()" />
		<hotspot name="case8" url="skin/infopoint.png" scale="0.7" ath="-24" atv="8" onhover="showtext(Case 8 - Miniature Clothing)" onclick="popup()" />
		<hotspot name="case9" url="skin/infopoint.png" scale="0.7" ath="26" atv="4" onhover="showtext(Case 9 - Finding Play)" onclick="popup()" />

		<!-- HOTSPOT PANEL -->
		<layer name="popup" type="container" align="center" alpha="0" bgalpha="0.9" bgcolor="0x9ECDBF" bgshadow="0 0 15 0x000000 1" maskchildren="true" visible="false" height="50%" width="500">
			<layer name="caseimage" url="" align="topleft" handcursor="false" onloaded="set(alpha,0); tween(alpha,1.0);" />
			<plugin name="title_text" url="%SWFPATH%/plugins/textfield.swf" html="" css="p{color:#FFFFFF; font-family:Arial; font-size:24; text-align:center}" keep="true" backgroundalpha="0" children="false" visible="true" width="250" height="100" align="lefttop" x="225" y="20" />
			<plugin name="url_button" url="%SWFPATH%/plugins/textfield.swf" html="[p]Explore this case further...[/p]" css="p{color: #FFFFFF; font-family: Arial; font-size: 16; text-align: center}" keep="true" align="righttop" autosize="center" autoheight="false" autowidth="false" backgroundcolor="0x558E7B" children="false" height="40" width="220" x="42" y="120" onclick="" />
			<layer name="info_text_container" type="container" align="lefttop" height="240" width="500" y="210">
				<layer name="info_text_scroll" url="%SWFPATH%/plugins/scrollarea.swf" alturl="%SWFPATH%/plugins/scrollarea.js" direction="v" mwheel="true" parent="info_text" align="lefttop" width="500" height="240">
					<plugin name="info_text" url="%SWFPATH%/plugins/textfield.swf" html="" css="p{color:#355C4F; font-family:Arial; font-size:16; margin-left:5; margin-right:5}" keep="true" backgroundalpha="0" children="false" visible="true" width="500" align="lefttop" />
				</layer>
			</layer>
			
			<plugin name="close_text" url="%SWFPATH%/plugins/textfield.swf" html="[p]CLOSE THIS WINDOW[/p]" css="p{color: #000000; font-family: Arial; font-size: 20; text-align: center}" keep="true" align="bottom" autosize="center" autowidth="false" backgroundcolor="0xFFFFFF" children="false" width="500" onclick="tween(layer[popup].alpha,0); set(layer[popup].visible, false);" />
		</layer>
		
		<?php
		$servername = "localhost";
		$username = "**MY USERNAME**";
		$password = "**MY PASSWORD**";
		$database = "**MY DATABASE**";
		
		$con = mysqli_connect($servername, $username, $password, $database);
		
		if($con) {
		  $query = "SELECT node.nid, node.title, field_revision_body.body_value FROM node INNER JOIN field_revision_body ON field_revision_body.entity_id = node.nid WHERE node.type = 'case_description' ORDER BY node.nid ASC";
		  $results = mysqli_query($con, $query);
		
		  while($row = mysqli_fetch_array($results, MYSQLI_ASSOC)) {
				$case_id = preg_replace("/[^0-9]/","",$row["title"]);
			echo '<data name="case'.$case_id.'" title="[p]'.$row["title"].'[/p]" body="[h2]'.$row["title"].'[/h2][p]'.$row["body_value"].'[/p]" image="case01_3_0.jpg" />';
		  }
		
		  mysqli_close($con);
		}
		
		?>
	</scene>


The hard-coded hotspots load in the pano, but the associated PHP-generated data does not appear when the hotspot is clicked. Hard-coding the <data> tags works, and I've checked the PHP code above outside of the framework and it produces the correct data. I've also tried embedding the PHP via a <?php <include url="data.php" /> ?> statement... nothing!

I'm at a complete loss. Does anyone have any idea at what I may try to get this working? Apologies if this has been explained elsewhere - I've had a good look but can't find anything though! *confused*

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

2

Donnerstag, 12. Mai 2016, 20:08

What is the name of the file:

tour.xml or tour.php *question*

Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

3

Donnerstag, 12. Mai 2016, 23:26

Thanks for the quick response Piotr! The file is called tour.xml... but I've just created a duplicate of this called tour.php, and I've updated tour.html to call this file rather than tour.xml. It still doesn't work I'm afraid!

Does anyone have the code for a working example they might be able to share with me? That way I could work through my code step by step and identify what might be wrong.

Thanks for the help!

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

4

Freitag, 13. Mai 2016, 10:37

try:

index.html to index.php

in this file:

Quellcode

1
2
3
...
embedpano({xml:"tour.php", target:"pano", html5:"prefer", passQueryParameters: true, initvars:{design:"tour"}, id:"krpanoSWFObject"}); 
...


and of course tour.xml to tour.php

Piotr
Your own professional, online cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

Timescale

Schüler

Beiträge: 120

Wohnort: Netherlands

Beruf: Archaeologist, Timescale R&D

  • Nachricht senden

5

Freitag, 13. Mai 2016, 13:42

When you load the tour file into the browser directly, how does the generated XML look? Is the data actually echo'ed and if so, are all the brackets and things correct? It's easy to miss a special character in long composite strings. Often it is cleaner to use another combination method like concatenating.

I also use php to generate KRpano tour files from a database and I have slowly but surely put everything is separate files that can be tested separately. Having the DB setup in just 1 file makes it a whole lot cleaner and easier to maintain.

If you could link or post the resulting XML. Ow and if stuff is missing, check the source in the browser. errors and mistakes could be hidden between point brackets and stuff.

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Timescale« (13. Mai 2016, 13:54)