We want to print our metadata keywords to the screen and link them to a search but when we do the following code all the words in the metadata field are printed as one link and not as individual links per keyword.
There was a post similar to this a while back, but I can't find it.
Your best bet is to split the the keywords at the ; and then create links for each. So, do something like:
var meta = 'test1;test2;test3;test4;test5;test6;test7';
// var meta = '%asset_metadata_keywords%'; in your case
// Split our string
meta = meta.split(';');
// loop through our values
for (i=0;i<=meta.length;i++) {
document.write(''+meta[i]+'');
}
This is just a quick and dirty example, but it shows how you can split those values apart. :)
[quote]
There was a post similar to this a while back, but I can't find it.
Your best bet is to split the the keywords at the ; and then create links for each. So, do something like:
var meta = 'test1;test2;test3;test4;test5;test6;test7';
// var meta = '%asset_metadata_keywords%'; in your case
// Split our string
meta = meta.split(';');
// loop through our values
for (i=0;i<=meta.length;i++) {
document.write(''+meta[i]+'');
}
This is just a quick and dirty example, but it shows how you can split those values apart. :)
[/quote]
Thanks for it seems to be workign although I get 'undefined' printed on screen after the last keyword.
[quote]
Thanks for it seems to be workign although I get 'undefined' printed on screen after the last keyword.
[/quote]
Yeah, it was just code that I wrote very quickly, so I did not have time to figure out why that was happening. If you don't have time or are not able to figure out why that is happening, let me know and I might have time to look at it again.
[quote]
Yeah, it was just code that I wrote very quickly, so I did not have time to figure out why that was happening. If you don't have time or are not able to figure out why that is happening, let me know and I might have time to look at it again.
[/quote]
Its ok, I fixed it. Thanks again for the JS though