Sie sind nicht angemeldet.

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

1

Mittwoch, 10. Februar 2016, 23:39

Is Conditional Include Possible?

How can we make including an XML conditional? Perhaps using calc?

I know how to use calc to construct a url string but I'm stumped on how to make it dependent on a condition.

2

Donnerstag, 11. Februar 2016, 08:47

Hi,

yes - see here (version 1.19):

http://krpano.com/docu/xml/#if

Best regards,
Klaus

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

3

Sonntag, 14. Februar 2016, 22:05

Brilliant!

It didn't work quite as I expected, however. If I use a variable, say skin_settings.webvr="true" and then use the conditional if="skin_settings.webvr == true" or if="skin_settings.webvr === true" it never resolves as true. But if="skin_settings.webvr" does resolve true/false correctly.

This seems different from how if works normally.

4

Freitag, 19. Februar 2016, 07:30

That would be strange...
Is your note still about using if on <include>?
If yes - see:

Zitat

Additionally there is one special case here - when using xml if checks on <include> elements, then the variables used in the if check, need to be defined before the current xml gets loaded. This could be done in the html file during embedding by using the initvars setting or in the xml before doing a loadpano() call.

Scott Witte

Fortgeschrittener

  • »Scott Witte« ist der Autor dieses Themas

Beiträge: 382

Wohnort: Milwaukee, WI USA

Beruf: Professional Photographer

  • Nachricht senden

5

Freitag, 19. Februar 2016, 17:16

I define skin_settings in tour.xml first (and removed that from vtourskin.xml entirely). I then included vtourskin.xml and then load the first scene. So:

TOUR.XML

Quellcode

1
2
3
4
5
6
7
8
9
10
<skin_settings
   webvr="true"
/>
<include url="skin/vtourskin.xml" />
<action name="startup" autorun="onstart">
     if(startscene === null OR !scene[get(startscene)], copy(startscene,scene[0].name); );
     loadscene(get(startscene), null, MERGE);
</action>
<scene name=.............>
</scene>
VTOURSKIN.XML

Quellcode

1
<include url="../plugins/webvr.xml" devices="html5" if="skin_settings.webvr == true"/>

With the above code webvr.xml does not load. But change it to:

Quellcode

1
<include url="../plugins/webvr.xml" devices="html5" if="skin_settings.webvr"/> 

Now webvr.xml loads -- and if I set skin_setting.webvr="false", webvr.xml does not load.

BTW, if I include vtourskin.xml first, before defining skin_settings, I get the same results. I assume this is because either way it is before the first pano is loaded?

Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »Scott Witte« (19. Februar 2016, 17:31)


6

Mittwoch, 2. März 2016, 16:20

Hi,

sorry, but that doesn't work - it is as the documentation say - 'the variables need to be defined before'!

The reason why:

Quellcode

1
if="skin_settings.webvr"
is working in your case is another one - a bug:

The expression 'skin_settings.webvr' in this case resolved to 'undefined' (because at the time when checking the if for the include is not defined) - and internally the xml 'if' checks were checked for not being 'false' - and then the comparison 'undefined != false' results wrong in true.

That means a - if="anything_that_is_not_defined_yet" - was wrongly working.

This will be fixed for the next release.

Best regards,
Klaus