Copied to clipboard

Flag this post as spam?

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


These support forums are now closed for new topics and comments.
Please head on over to http://eureka.ucommerce.net/ for support.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 30, 2014 @ 11:15
    Dennis Aaen
    0

    Use standard Umbraco datatypes

    Hi,

    I was wondering if it's possible to use standard Umbraco data types in Umbraco, on category definitions and product definitions in uCommerce.

    I was thinking of using the Multi-Node Tree Picker, we are using this on standard pages in the shop for picking some spot elements, and I would like to do the same on a category or product page, if possible.

    On standard webpages in the store, I can do something like this.

    @inherits umbraco.MacroEngines.DynamicNodeContext                                                     
    @if (Model.HasValue("contentElementMain")){
        foreach (var item in Model.contentElementMain){
            var node = Library.NodeById(item.InnerText);
    
            if (node.NodeTypeAlias == "NewsSpot"){
                <aside class="newsSpot box">
    
                    <div class="boxContentWrapper">
    
                        @if (node.HasValue("newsSpotDate")){
                            <span class="date">
                                @node.newsSpotDate.ToString("dd-MM-yyyy")
                            </span>
    
                            if (node.HasValue("newsSpotHeader") || node.HasValue("newsSpotBody")){
                                <div class="content">
                                    @if (node.HasValue("newsSpotHeader")){
                                        <h2>
                                            @node.newsSpotHeader
                                        </h2>
    
                                    }
                                    @node.newsSpotBody
                                    @if (node.HasValue("newsSpotLink")){
                                        <a href="@node.newsSpotLink">@Dictionary.ReadMore</a>
                                    }
    
                                </div>
                            }
    
                        }
    
                    </div>
                </aside>
            }
        }
    
    }
    

    Does anyone know if I can use the standard Multi-Node Tree Picker, and if how to get data out of it, when I am on a category page or product page.

    Any help will be appreciated,

    /Dennis

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jul 31, 2014 @ 08:22
    Nickolaj Lundgreen
    0

    Hi Dennis

    I haven't used the datatypes myself - but on Umbraco 6 shops you are able to use umbraco-datatypes (i don't think this feature is ready for Umbraco 7). Small guide from Jesper here:

    http://our.umbraco.org/projects/website-utilities/ucommerce/ucommerce-support/45005-How-to-configure-umbraco-datatypes-in-ucommerce

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 31, 2014 @ 10:07
    Dennis Aaen
    0

    Hi Nicklaj,

    Thanks, for the reference, I am now a step closer to get it to work.

    I have done it like this, but I am insecure what to call in my foreach loop to get the actual XML foreach item, than just the items id´s

    With this I can get the id´s there are selected:

    @{
        Category category = SiteContext.Current.CatalogContext.CurrentCategory;
        var contentElmProperty = @category.GetProperty("LeftContentElements", "da-DK");
        var element = contentElmProperty.GetValue();

         @element
    }

    This gives the output.

    <MultiNodePicker type="content"><nodeId>4858</nodeId> <nodeId>4872</nodeId> <nodeId>4859</nodeId></MultiNodePicker>

    But if I try something like this:

    @foreach(var item in element){
    }

    Visual Studio tells me that the element type object is not enumerable

    Did you have any idea on how I get the XML instead of the Id´s

    Any help will be appreciated,

    /Dennis

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jul 31, 2014 @ 10:12
    Nickolaj Lundgreen
    0

    Seems like you are only missing a deserializing.

    Maybe something like this: http://our.umbraco.org/wiki/reference/code-snippets/razor-snippets/get-values-from-ucomponents-multi-node-tree-picker-multiple-textstring Would return the nodes you are looking for?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 31, 2014 @ 10:25
    Dennis Aaen
    0

    Hi Nickolaj,

    I am not sure what you are meaning by it seems like you are only missing a deserializing. Maybe you could show how my foreach loop should look like. The difficult part for me is that we are in uCommerce context and not standard Umbraco.

    Hope you can help.

    /Dennis

     

  • Nickolaj Lundgreen 233 posts 1132 karma points
    Jul 31, 2014 @ 10:34
    Nickolaj Lundgreen
    100

    Hi Dennis.

    You can have both a uCommerce and a Umbraco context. Just add a category/catalog/product node in the umbraco tree, with the url used in uCommerce rewrite-rules (i can elaborate on that, if you want).

    Regarding the multinodes:

    Category category = SiteContext.Current.CatalogContext.CurrentCategory;
    var contentElmProperty = @category.GetProperty("LeftContentElements", "da-DK");
    var element = contentElmProperty.GetValue().ToString();
    var nodes = uQuery.GetNodesByXml(element);
    
    foreach(var node in nodes)
    {
        @node.Name
    }
    

    (Just by memory - maybe you can get some inspiration if it doesn't work out of the box)

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 31, 2014 @ 10:42
    Dennis Aaen
    0

    Hi Nickolaj,

    Thanks for you help, appreciate it.

    And with your code I now get the name of the of the elements that there are selected.

    So it works like it should.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft