Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am using uComponents textstring array datatype to list social media icons with a url and a value..
I have used the razor example from here http://ucomponents.org/data-types/textstring-array/ but I can't figure out how to get each specific value in a row?
In the xslt example the syntax is value[1] and value[2], but in the razor example @cell outputs all values in the row.. how can I get each value node?
<TextstringArray> <values> <value>hello</value> <value>world</value> </values> <values> <value>foo bar</value> <value>world</value> </values> </TextstringArray>
/Bjarne
Hi Bjarne,
Give this a try:
<table> @foreach (var row in textstringArrayPropertyAlias) { <tr> @foreach (var cell in row) { <td>@cell.InnerText</td> } </tr> } </table>
Jeavon
I should explain further, the example is using the Razor Model Binding but if you don't have that enabled (or are using Mvc), the type will be DynamicXml which I think is what you have.
Are you using Mvc?
Hi Jeavon
I also tried that, but I then get a error that string doesn't contains a defination for InnerText.
Right now I have this:
@using umbraco.MacroEngines @inherits umbraco.MacroEngines.DynamicNodeContext <div class="footerText"> <ul> @foreach (string[] row in Model.NodeById(1054).socialNetworks) { <li> @foreach (var cell in row) { @cell; } </li> } </ul> </div>
Which outputs this:
<div class="footerText"> <ul> <li>Facebookhttps://www.facebook.com</li> <li>Instagramhttp://instagram.com/</li> </ul> </div>
I would like to split the values up into something like this:
<div class="footerText"> <ul> <li><a href="https://www.facebook.com" target="_blank" title="Facebook">Facebook</a></li> <li><a href="http://instagram.com/" target="_blank" title="Instagram">Instagram</a></li> </ul> </div>
No, the rendering engine is set to WebForms :)
Ok, so you have the uComponents Razor Model Binding set to true in Web.Config?
I haven't a key in with that in web.config, but I think it's activated since a see this message under uComponents activator dashboard tab:
Have you tried?
@foreach (string[] row in Model.NodeById(1054).socialNetworks) { <li> @foreach (var cell in row) { @cell[0] @cell[1] } </li> }
Yep.. tried that too.. but I think it gives me a weird output ..
<div class="footerText"> <ul> <li>Faht</li> <li>Inht</li> </ul> </div>
It seems to take the two first characters Fa from Facebook and ht from http://facebook.com .. and the for Instagram in this case..
Ok, one last go for today:
@foreach (string[] row in Model.NodeById(1054).socialNetworks) { <li> @row[0] @row[1] </li> }
Ahh, that looks much more pretty :)
<div class="footerText"> <ul> @foreach (string[] row in Model.NodeById(1054).socialNetworks) { <li> <a href="@row[1]" target="_blank" title="@row[0]">@row[0]</a> </li> } </ul> </div>
Output:
<div class="footerText"> <ul> <li> <a href="http://facebook.com" target="_blank" title="Facebook">Facebook</a> </li> <li> <a href="http://instagram.com" target="_blank" title="Instagram">Instagram</a> </li> </ul> </div>
Thanks.. just what I was looking for.. :)
Phew! Glad it's working now.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Get each "column" value in textstring array
I am using uComponents textstring array datatype to list social media icons with a url and a value..
I have used the razor example from here http://ucomponents.org/data-types/textstring-array/ but I can't figure out how to get each specific value in a row?
In the xslt example the syntax is value[1] and value[2], but in the razor example @cell outputs all values in the row.. how can I get each value node?
/Bjarne
Hi Bjarne,
Give this a try:
Jeavon
I should explain further, the example is using the Razor Model Binding but if you don't have that enabled (or are using Mvc), the type will be DynamicXml which I think is what you have.
Are you using Mvc?
Hi Jeavon
I also tried that, but I then get a error that string doesn't contains a defination for InnerText.
Right now I have this:
Which outputs this:
I would like to split the values up into something like this:
/Bjarne
No, the rendering engine is set to WebForms :)
Ok, so you have the uComponents Razor Model Binding set to true in Web.Config?
I haven't a key in with that in web.config, but I think it's activated since a see this message under uComponents activator dashboard tab:
Have you tried?
Yep.. tried that too.. but I think it gives me a weird output ..
It seems to take the two first characters Fa from Facebook and ht from http://facebook.com .. and the for Instagram in this case..
Ok, one last go for today:
Ahh, that looks much more pretty :)
Output:
Thanks.. just what I was looking for.. :)
/Bjarne
Phew! Glad it's working now.
Jeavon
is working on a reply...