Is Conditional Include Possible?

  • 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.

  • 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.

  • 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

    Code
    <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

    Code
    <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:

    Code
    <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?

  • Hi,

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

    The reason why:

    Code
    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

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!