Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Feb 20, 2015 @ 20:37
    Craig100
    0

    How to retrieve value from Archetype fieldset?

    V7.2.1 Umbraco Core Property Value Converters (UCPVC) installed

    I know this is to do with Archetype but there's no problem if I don't have UCPVC installed. So........

    I have an Archetype field set which I can get an image from a Media Picker ok but am unable to retreive a simple textbox value.  I know that when I haven't had UCPVC installed, in the following code, to get the H4 I'd just use fieldset.GetValue("subSectionTitle"). I'm afraid I can't work out how to get to it with the UCPVC installed.

    Code:-

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Archetype.Models;
    @using Archetype.Extensions;
    @{
        var subSections = Model.Content.GetPropertyValue<ArchetypeModel>("pageSections");
    }
    <div>
      <ul>
            @{int counter = 1;}
            @foreach(var fieldset in subSections){  
            var icon = Umbraco.TypedMedia(fieldset.GetValue("icon"));
            <li>
                <div>
                    <a href="#tabs-@counter" title="@icon.Name"><img src="@icon.GetResponsiveCropUrl("SupportIcon")" alt="@icon.Name"></a>
                    <h4>@fieldset.GetProperty("subSectionTitle").Value.ToString()</h4>
                </div>
            </li>
            counter++;
            }
        </ul>
    </div>

    Result:-

    Compiler Error Message: CS1061: 'Archetype.Models.ArchetypeFieldsetModel' does not contain a definition for 'GetProperty' and no extension method 'GetProperty' accepting a first argument of type 'Archetype.Models.ArchetypeFieldsetModel' could be found (are you missing a using directive or an assembly reference?)

    Have tried several ways but no luck.

    Any clue would be appreciated.

    Thanks,

    Craig

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 20:50
    Jeavon Leopold
    100

    I think it should be GetValue?

              <h4>@fieldset.GetValue("subSectionTitle")</h4>
    
  • Craig100 1136 posts 2523 karma points c-trib
    Feb 20, 2015 @ 21:05
    Craig100
    0

    Thanks Jeavon.

    You're absolutely right. I deleted this topic within 5 mins of posting it (having tried for an hour). Typo!

    Deleting topic doesn't seem to work :(

    Craig

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 21:09
    Jeavon Leopold
    0

    No worries, is "icon" a media picker?

  • Craig100 1136 posts 2523 karma points c-trib
    Feb 20, 2015 @ 21:13
    Craig100
    0

    Yes

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 21:29
    Jeavon Leopold
    0

    Then you can do this:

    var icon = fieldset.GetValue<IPublishedContent>("icon");

    Which will use the value converter

  • Craig100 1136 posts 2523 karma points c-trib
    Feb 20, 2015 @ 21:42
    Craig100
    0

    er... now it's broke at @icon.GetResponsiveCropUrl("SupportIcon")

    :(

  • Craig100 1136 posts 2523 karma points c-trib
    Feb 20, 2015 @ 21:43
    Craig100
    0

    No it isn't!

    What it is, is time to stop working!

    Have good evening, I'm opening a bottle :( !

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Feb 20, 2015 @ 21:51
    Jeavon Leopold
    0

    You too!

  • 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