Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • marmar 35 posts 28 karma points
    Aug 23, 2013 @ 02:58
    marmar
    0

    textstring array razor macro uComponents

    using the documented example from ucomp's site. Perhaps I am missing something - (textstringArrayPropertyAlias, is changed to my parameter alias)

    @inherits umbraco.MacroEngines.DynamicNodeContext
    <table>
        @foreach (string[] row in Model.textstringArrayPropertyAlias)
        {
            <tr>
                @foreach (var cell in row)
                {
                    <td>@cell</td>
                }
            </tr>
        }
    </table>
    

    my issue is that it is not returning anything... ive tried a number of things,

    @{var propertyItem = Property.PropertyAlias
    {
    @PropertyAlias
    

    produces the property type for the macro on the template as string, so I know that I am correctly inserting the Macro, just cant seem to get any values from the macro to appear. - also there is no errors, just no values from the array

    any pointers?

    (umbraco 6.1.4, uComponents_5.5.0, IIS 7.0, .NET VersionASP.Net 4.0/4.5)

    Thanks guys!

    Marc

  • Lee Kelleher 4026 posts 15837 karma points MVP 13x admin c-trib
    Aug 23, 2013 @ 09:11
    Lee Kelleher
    0

    Hi Marc,

    If you output just @Model.textstringArrayPropertyAlias what is displayed?

    I'm hoping it's a List<string[]> (or similar)

    Thanks, Lee.

  • marmar 35 posts 28 karma points
    Aug 23, 2013 @ 17:22
    marmar
    0

    Hi Lee! Wow thanks for the response.

    I unfortunately do not get anything.. when I output @Model.textstringArrayPropertyAlias

    but I do get the value of the propertyType alias when I use:

    @{var propertyItem = Property.PropertyAlias
    }
    @propertyItem 
    

    So the implementation is exactly what you have in your demo and documentation for the text string Array data type. http://ucomponents.org/data-types/textstring-array/

    2 fields,

    it should be a List<string[]> but its strangely not liking the razor macro.


    for completeness here are all the areas touched for this section:

    Sorry if this overkill - but I wanted to include for completeness

    Data Type FAQ String Array Settings: DocType field cshtml script

    @inherits umbraco.MacroEngines.DynamicNodeContext 
    
    @Model.FAQPropAlias
    <table>
    @foreach (string[] row in Model.FAQPropAlias)
        {
            <tr>
                @foreach (var cell in row)
                {
                    <td>@cell</td>
                }
            </tr>
        }
    
    </table>
    

    Macro Macro parameter

    razor macro insertion

    <umbraco:Macro FAQPropAlias="fAQSectionQA" Alias="FAQStringArrayMacro" runat="server"></umbraco:Macro>
    

    thanks again for your help

    Marc

  • David 6 posts 28 karma points
    Feb 28, 2014 @ 17:42
    David
    0

    I've noticed that when textstring array is used in a Media item all that is returned from that property is a string. I did find a way to convert it into a List but I wish it would just automatically return it... Not sure why the Media section would return different results then the Content section.

     

    umbraco.cms.businesslogic.Content mediacontent = new umbraco.cms.businesslogic.Content(media.Id);
    var deserializer = new JavaScriptSerializer();
    var items = deserializer.Deserialize<List<string[]>>(mediacontent.getProperty("textstringarrayprop").Value.ToString());
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies