Hi,
I created an index builder extender saving a string array. Now using the QueryPublisher I am not able to use the values saved there. How could I get using standard tags?
Best Regards,
Nuno Aguiar
Hi,
I created an index builder extender saving a string array. Now using the QueryPublisher I am not able to use the values saved there. How could I get using standard tags?
Best Regards,
Nuno Aguiar
Hi Nuno
I do not understand.
BR Nicolai
Hi Nicolai,
Here's what I mean. And I made a few tests as well so I have it working as I need it, I just want to understand what to expect out of the platform:
I created the field as String array https://www.screencast.com/t/wVQ5fQ8OKWH. I was expecting to do something like:
var fileDescriptions = item.GetValue("FileFriendlyName");
foreach (var description in fileDescriptions) {
...
}
The output though is not an array (because DW's template engine does not return string arrays) https://www.screencast.com/t/evuKGy8DsE. And now that I spell this out I kind of realize I would never get this, unless it would be converted into a Loop.
So I guess my question now is:
Best Regards,
Nuno Aguiar
Hi Nuno
It is returned as system.object containing the type that is in the index, in this case a string array - so you get a string array from GetValue - so no loop.
Here is a sample from the default template - you should be able to use that.
@foreach (var result in GetLoop("QueryResultItem"))
{
<li class="result-item">
<table>
@foreach (var prop in result.GetLoop("Properties"))
{
<tr>
<td class="name">@prop.GetValue("Name")</td>
<td class="value">
@prop.GetValue("Value")
@{
if (prop.GetValue("Value").GetType() == typeof(bool[]))
{
<br />
foreach (bool b in (bool[])prop.GetValue("Value"))
{
<text>@b.ToString()<br /></text>
}
}
if (prop.GetValue("Value").GetType() == typeof(String[]))
{
<br />
foreach (string s in (String[])prop.GetValue("Value"))
{
<text>@s<br /></text>
}
}
}
</td>
</tr>
}
</table>
</li>
}
Hi Nicolai,
Gotcha, thanks for showing me that. I'll bookmark it in my documentation ;)
Best Regards,
Nuno Aguiar
You must be logged in to post in the forum