Copied to clipboard

Flag this post as spam?

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


  • Stephen 47 posts 270 karma points
    Aug 17, 2018 @ 08:11
    Stephen
    0

    Creating Stacked/Inner Content programmatically

    Hi,

    I'm looking to populate content programatically that has a property that is a Stacked Content datatype.

    Most of the code I can see in InnerContent seems to be dealing with converting from the existing property value - is there something already there I can hook into, or an existing object I can create and serialize?

    Otherwise I guess I'll have to create a class with the same properties that you're serializing (key, name, icon, icContentTypeGuid) and serialize it along with the property values I need.

    Stephen

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 17, 2018 @ 08:21
    Lee Kelleher
    0

    Hi Stephen,

    Yeah, as you say, there's nothing in Inner/Stacked Content that will aid you creating items programmatically... and yes, (as you mentioned), the raw value would need to be a JSON string, like so...

    [
        {
            "key": "00000000-0000-0000-0000-000000000000",
            "name": "Content Name",
            "icon": "icon-o-icon",
            "icContentTypeGuid": "00000000-0000-0000-0000-000000000000",
            "alias1": value1,
            "alias2": value2
            ...
        }
    ]
    

    The only reason we haven't added code for this, is that we haven't had a personal/client need for it yet.

    If you do end up making any generic helper methods to help with this, I'd be open for contributions for Inner Content.

    Cheers,
    - Lee

  • Stephen 47 posts 270 karma points
    Aug 17, 2018 @ 08:44
    Stephen
    0

    OK, as long as I know I'm not recreating something that you've already done.

    One of the tricky bits looks like getting the name property because I don't have access to angular's $interpolate to generate it, I might have to just stick with the doctype name for now.

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Aug 17, 2018 @ 08:47
    Lee Kelleher
    0

    Nope, definitely not recreating anything :-)

    With the name, you could try C# string interpolation? e.g. $"Some feature: {alias1}" ... Update, ignore me, I'd forgot about the DataType config.

Please Sign in or register to post replies

Write your reply to:

Draft