variables in plugins

  • I think I can make this xml easier:

    <plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />

    In php I would use variables, but I don't know if that is also possible in krpano xml?

    The way I 'call' the plugin is:
    <plugin name="thumb_blah" url="skin/thumbs/blah.jpg" x="0" y="28" onhover="showtext(blabla);set(plugin[thumb2_blah].visible,true);" onout="set(plugin[thumb2_blah].visible,false);" onclick="loadpano(blah.xml);" />

    Is it possible to use only one line instead of 5 (in my case 24)? If yes, how?

    Thanks in advance! And it's a pity the documentation on the website is not so good / updated.

  • Hi maaike,

    Perhaps you can define a generic thumb2_ plugin and set dynamically his url and visibility ...
    Something like this:

    Code
    <plugin name="thumb2_generic" url="" keep="true"  x="5" y="5" visible="false" />
    
    
    <plugin name="thumb_blah" url="skin/thumbs/blah.jpg" x="0" y="28"
    	onhover="showtext(blabla);"
    	onover="set(plugin[thumb2_generic].url,skin/thumbs/blah.jpg);set(plugin[thumb2_generic].visible,true);"
    	onout="set(plugin[thumb2_generic].visible,false);"
    	onclick="loadpano(blah.xml);" />

    SAlut.

  • Is it possible to use only one line instead of 5 (in my case 24)? If yes, how?

    Do this in one line? Sure!

    Code
    <plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" /><plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />


    Just kidding... *g*

    Here's how you would do it with variables and actions:


    The action make_plugins takes 3 arguments. The name prefix, the url prefix, and the number of plugins to create. The syntax to call it is:

    Code
    make_plugins(thumb2_blah,skin/thumbs/blah,5);


    This recursively makes the thumbs thumb2_blah5, thumb2_blah4, thumb2_blah3, thumb2_blah2, thumb2_blah1. I'm assuming that it is okay for the first thumb to be named thumb2_blah1 rather than thumb2_blah as you showed in your post. If you truly need it to be thumb2_blah (without the 1) simply add an if statement.

    Here's a more complex version that uses an array to store the titles for the showtext, and sets the onhover, onout, and onclick values:

    Hope this helps

    steve

    Edited once, last by pinsane (May 19, 2010 at 10:43 PM).

  • Hi ,
    i try to understand this for a while but i get crazy with tha %1 etc thing..
    what does that exactely mean?..

    and what when %1%3... how does it now what to get /do..

    so i get this..

    -------
    when this is the action call:

    test(abc,123,xyz);

    and this the action:

    <action name="test">
    trace('name of the action=', %0);
    trace('p1=', %1);
    trace('p2=', %2);
    trace('p3=', %3);
    </action>

    then the %0 - %9 placeholders will be replaced by
    the given parameter,

    e.g. for:

    test(abc,123,xyz);

    %0 = test
    %1 = abc
    %2 = 123
    %3 = xyz

    so the code will become:

    <action name="test">
    trace('name of the action=', test);
    trace('p1=', abc);
    trace('p2=', 123);
    trace('p3=', xyz);
    </action>
    ----

    i understand.. almost but... how does it now which plugin... *confused*

    Thanx
    Tuur

  • Hi,

    <plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah2" url="skin/thumbs/blah2.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah3" url="skin/thumbs/blah3.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah4" url="skin/thumbs/blah4.jpg" keep="true" x="5" y="5" visible="false" />
    <plugin name="thumb2_blah5" url="skin/thumbs/blah.jpg5" keep="true" x="5" y="5" visible="false" />

    you could use the <style> tag in the xml to share the same attributes,
    e.g.

    Quote

    <style name="xyz" keep="true" x="5" y="5" visible="false" />

    <plugin name="thumb_blah" url="skin/thumbs/blah.jpg" style="xyz" />
    <plugin name="thumb2_blah" url="skin/thumbs/blah.jpg" style="xyz" />
    <plugin name="thumb3_blah" url="skin/thumbs/blah.jpg" style="xyz" />
    ...


    Quote

    In php I would use variables, but I don't know if that is also possible in krpano xml?

    if you want you could still use php to generate the xml,


    Thanks in advance! And it's a pity the documentation on the website is not so good / updated.

    at the moment I'm working really hard on it, it should have been released already last week

    best regards,
    Klaus

  • Thank you for the clear answers! It work very much like I'm used to ;). Thanks, I'll try. Also style makes it a lot easier!!

    I know I can generate an xml with php, but I want to know more about the 'krpano scripting', because sometimes that's easier with clients.
    And Klaus, I'm looking forward to the very good documentation ;). I know that's a lot of work.

Participate now!

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