how to use dynamic custom xml parameter?

  • Hi,

    I wish to pass custom xml variable ("imgpath" in this case) but I don't know how to
    use it inside xml.

    Code
    embedpano({swf:"krpano.swf", xml:"xml.xml", target:"krpano", vars:{imgpath:"http://localhost"}});

    I know in the xml action I can use it using "get(imgpath)" but I need to use it in the panorama image
    url attribute - <cube url="get(imgpath)/1/pano_%s_%v_%u.jpg" />

    Is this possible or do I have to use actions?

    Any comments would be appreciated.
    hyung

  • Hi,

    first - the passed 'vars' will be passed to the viewer AFTER parsing the xml - that means when using trying to use the passed variables for url paths it would be too late. To bypass this you could need to load a second xml - or use 'null' as xml parameter and specific an onstart event to load the first xml.

    e.g.

    Code
    embedpano({xml:null, ..., vars:{onstart:"loadpano(pano.xml);", imgpath:"..."}});


    second - for using variables in url paths, placeholders can be used (using get() is not possible there) - see here:
    https://krpano.com/docu/xml/#urlplaceholders

    e.g.

    Code
    url="%$imgpath%/..."

    Best regards,
    Klaus

  • It doesn't appear to be a specific enough reference and it appears that you are trying to set some base url for select image paths. While you should use the basepath ( https://krpano.com/docu/html/#basepath ) parameter during embedding, since you may run into some cross domain issues, you could try storing your variable information in a data element and referencing that ( https://krpano.com/docu/xml/#data ).

    Thank you cgspicer,

    I haven't tried it yet but I believe Klaus' answer seems to solve the problem!

    Best Regards,
    Hyung

Jetzt mitmachen!

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