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:
<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>
Alles anzeigen
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!