Copied to clipboard

Flag this post as spam?

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


  • Phil 54 posts 139 karma points
    Jan 29, 2015 @ 16:06
    Phil
    0

    Default value of drop down list property on document type

    Hi all,

    Experiencing some strange behavior here on 7.2.0.

    I have a drop down list property attached to a document type. This property is not mandatory.

    However, if I don't select a prevalue from the drop down list when creating content (leaving the drop down list blank), then the property value is set to "23". Is this normal behavior? I was expecting either a blank string, or a null value!

    Many thanks.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 16:17
    Jan Skovgaard
    0

    Hi Phil

    Could you show a screendump of what it looks like in your backoffice? It should just return a falsy value like empty, 0, null for instance I think.

    /Jan

  • Phil 54 posts 139 karma points
    Jan 29, 2015 @ 16:22
    Phil
    0

    Jan,

    I have discovered that the drop down property was actually mandatory - changing the property to non-mandatory returns an empty string as I expected.

    However, when creating the content with the property set to mandatory, I was able to successfully create without setting a value. This is no longer the case - when I change to property back to mandatory, I cannot create content without selecting from the drop down (as expected!)

    Very unusual, but seems to have resolved itself! :)

  • Phil 54 posts 139 karma points
    Jan 29, 2015 @ 16:43
    Phil
    0

    Jan,

    As a somewhat related problem, I am attempting to get all nodes where the value of the drop down list property is equal to a certain string, or has not been specified:

    var nodeList = CurrentPage.AncestorOrSelf(1).Descendants("myDocumentType")
        .Where("property = @0 || property = @1", "value", "");
    

    However, this always returns nothing. What is the best way to go about this?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jan 29, 2015 @ 18:01
    Jan Skovgaard
    0

    Hi Phil

    Well that's probably because you're asking for those "myDocumentType" aliases where the value is either "value" or empty.

    I think that you should instead be able to do this

    var nodeList CurrentPage.AncestorOrSelf(1).Descendants("myDocumentType");
    
    @foreach(var node in nodeList){
    
      if(!string.IsNullOrEmpty(node.ToString())){
         @node
      }
    
    }
    

    Does this work?

    /Jan

  • Phil 54 posts 139 karma points
    Jan 30, 2015 @ 09:47
    Phil
    0

    Jan,

    I don't think that that will achieve what I am after - let's say that I have a document type called Blog, which has three properties:

    • Title textstring
    • Category dropdownlist
    • Body RTE

    I am attempting to create a paged list of blogs, so I need to extract all blogs into a variable before displaying so that I can evaluate the count.

    However, in the list of blogs, I would like to show blogs where the category is equal to "Tutorial" or the category has not been selected.

    How would I be able to select a list of blogs that have a category of "Tutorial" or a category of ""?

  • 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