Copied to clipboard

Flag this post as spam?

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


  • Carlos Casalicchio 176 posts 736 karma points
    Sep 06, 2013 @ 19:20
    Carlos Casalicchio
    0

    Loading a DataType value into a Macro

    Folks,

    Maybe my logic was incorrect when creating a DataType/Macro for umbraco, but here it is:

    I'm creating a social media links datatype that displays a list of social channels for the user.

    The data is being saved as Json "{ChannelID:'Twitter',Url:'http://www.twitter.com/user'}"

    The DataType is saving fine, but I'm having a hard time figuring out how to pull this data to render it as a macro.

    I want to create a macro that will render html based on the channel and url. The macro will be similar to the DataType except that it won't show the textbox.

    How do I load the data? I'm new at extending umbraco so am not even sure which table this data went to, or even if there's a helper that will load it for me!

    social media channels dataType

    I can post code if necessary, in case my question isn't clear enough.

  • Carlos Casalicchio 176 posts 736 karma points
    Sep 11, 2013 @ 03:52
    Carlos Casalicchio
    0

    Does anyone have anything to say about this question???

  • Carlos Casalicchio 176 posts 736 karma points
    Sep 11, 2013 @ 17:38
    Carlos Casalicchio
    0

    I've been able to figure this out: My macro has a NodeID parameter and since the data is serialized (json), then I'm using a Json Deserialize helper

    @{
    var nodeId = Parameter.NodeID;
    DynamicNode node = Library.NodeById(nodeId);
    Social_Media_List list = JsonHelper.JsonDeserialize<Social_Media_List>(node.PropertiesAsList[0].ToString());
    
    Response.Write(list.List[0].Url); }
    
Please Sign in or register to post replies

Write your reply to:

Draft