Defining URLs through CALC expression

  • Hello there!

    I'm struggling by defining URL's automatically with CALC action. My current code is:

    Code
    <style name="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn" url="calc:'%HTMLPATH%/thumbs/' + name + '.png'"/>
    
    
            <hotspot name="hs1" style="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn"/>
            <hotspot name="hs2" style="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn"/>
            <hotspot name="hs3" style="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn"/>
            <hotspot name="hs4" style="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn"/>
            <hotspot name="hs5" style="thumbstyle" attribute1="val1" attribute2="val2" ... attributen="valn"/>

    But then I get a krpano report of URLs being defined as: "/thumbs/undefined.png"

    So, my question is how to refer to a layer/hotspot name inside a "calc:" expression.

    Thanks! *thumbup*

    Luis

  • Hi,

    that's not possible!

    The 'get:' an 'calc:' are special values for xml-attributes that will be resolved during the xml parsing - see here:
    https://krpano.com/docu/xml/#xmlget

    So when there is just a 'calc:name' - that 'name' would refer to a global variable named 'name' - but as there no such variable 'undefined' will be returned.

    Additionally that 'calc:' will only refer to the attribute value itself, there is no context like <style> at this time.

    The style="..." attributes will be resolved in a later step where the 'get:' and 'calc:' attributes where already resolved, so using a 'calc:' in a style for later usage in <hotspot> isn't possible.

    That <style> is a just collection of attributes that will be set for an other element, but it can't be used as template-engine.

    I understand what you're trying to do, but that's not possible this way.
    Consider using dynamic action code (e.g. addhotspot calls) - this way you have more possibilities and more flexibility.

    Best regards,
    Klaus

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!