Sie sind nicht angemeldet.

1

Donnerstag, 30. April 2020, 15:16

Language switch via data: ?

Hi,
beside switching between different language content via different folders (https://krpano.com/forum/wbb/index.php?p…&threadID=17499) I need to open different URLs depending on the choosen language.

My idea is, to simply use a data: set to store the links. Is it possible to do this?

e.g.:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    	...
		</data>
		<data name="url_infopoint-box5startlink-de">	
		https://.../produkte/beispiel.html
		</data>
		 
		<data name="url_infopoint-box5startlink-en">	
		https://.../products/example.html
		</data>

		<data ...


<layer name="box5startlink" type="image" style="linkspotstyle" url="skin/linkspot.png" onclick="a_openlocalizedurl(box5startlink,get(v_lang));"  />		

	<action name="a_openlocalizedurl">
					openurl(data[url_infopoint-%1-%2].content)';
	</action>

I know the last part is not right, but I have missed the right way to transform the data.content into a variable or use it directly to open the url. I tried several things, but I'm a bit worried, that I'm on the wrong track completely.

Quellcode

1
2
3
4
5
	<action name="a_openlocalizedurl">
					trace(data[url_infopoint-%1-%2].content);
<!--					set(urlloc,data[url_infopoint-%1-%2].content);-->
					copy(urlloc, get(data[url_infopoint-%1-%2].content));
	</action>



I very much would appreciate some hint, why this is not working.

Yours,

Michael

2

Donnerstag, 30. April 2020, 16:37

you're not on the wrong track, you can do it that way ...

seems more a problem of understanding set, get and copy (?)
---> if a and b are variables

your code:
set(a,b); --> a = "b", not the content of b
copy(a, get(b)); --> you could do that if b="c" and you want the content of variable c (is not the case here)

what you want is: set(a, get(b)); --> a = content of b
or shorter: copy(a, b); --> a = content of b

most krpano actions expect direct content for their arguments, not variables
for these you need get() to replace the variable by its content
exceptions are : copy, trace, debug, error, warning (and some others)

for your thing this probably works... (openurl expects an url, not a variable)

Quellcode

1
2
3
<action name="a_openlocalizedurl">
    openurl(get(data[url_infopoint-%1-%2].content));
</action>
(untested)

Dieser Beitrag wurde bereits 9 mal editiert, zuletzt von »indexofrefraction« (30. April 2020, 17:13)


3

Samstag, 2. Mai 2020, 00:52

"copy(a, get(b)); --> you could do that if b="c" and you want the content of variable c (is not the case here)"
"most krpano actions expect direct content for their arguments, not variablesfor these you need get() to replace the variable by its content

exceptions are : copy, trace, debug, error, warning (and some others)"


Thanks so much for this insight!! I have been bashing my head on a keyboard for two straight days and this was the solution. Seriously, I clocked 8 hours trying to fix a bug caused by this *cry* . I am writing a similar piece of code to what Mstoos is trying, except in my case the data element contains a huge list of values/text/addresses that are bracketed by unique identifiers. So I was making a "retrieve" action that looks for those unique bracketing identifiers and extracts the values/text/address. If anyone wants the action just say so and I'll clean it up and post it (not that it is terribly complicated, but maybe I can help some one from troubleshooting something similar).


I guess my mistake was I had a situation where a = "b". Then when I was troubleshooting why the action wasn't resolving correctly, I found my self using trace. Trace('the value of a is: ', get(a)) would return the correct value, so I made the assumption that the correct value was being passed on to the rest of my action!


Thanks Indexofrefraction for taking the time to clarify this nuance of Krpano. *thumbup*