Copied to clipboard

Flag this post as spam?

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


  • Stephen 204 posts 246 karma points
    Oct 10, 2011 @ 18:08
    Stephen
    0

    checkbox content from site content?

    I'm creating a form for a user to fill out, i want to list the offices in a checkbox list to allow the use to select an office from the list.  I know i can create the checkbox list datatype with pre defined values but the cleaver way would be to list the offices based on the thier document type from the main site.

    That way if the client add another office to the site or rename the office my checkbo list will auto update.

    Is there a way to do this?

    S

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 10, 2011 @ 20:38
    Dirk De Grave
    0

    Stephen,

    Are you trying to do this from xslt? Or Razor? Some starting code snippets:

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc]//* [name() = 'aliasOfDocumentType']>
      <input type="checkbox" name="" id="" value="{./@nodeName}"><xsl:value-of select="@nodeName" /></input>
    </xsl:for-each>
    @foreach (var node in @Model.NodeById(-1).Descendants("aliasOfDocumentType")) {
      <input type="checkbox" name="" id="" value="@node.Name"><xsl:value-of select="@node.Name" /></input>
    }

     

    Hope this helps.

    Regards,

    /Dirk

     

  • Stephen 204 posts 246 karma points
    Oct 11, 2011 @ 10:07
    Stephen
    0

    thats ideal Dirk, i'll maybe try the razor version as I've been meaning to get into this...this leads me to another question...

    I've created a member type which contains additional info on the staff member and I've created a new property for office/location, how would i get the new checbox list t appear in my type dropdown or should i go about this in a different way?

    S

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Oct 11, 2011 @ 10:22
    Hendy Racher
    0

    Hi Stephen,

    If you want a checkbox / dropdown list in the Umbraco back office (to be populated with content nodes), the uCompoents XPathCheckBoxList or XPathDropDownList could be useful.

    HTH,

    Hendy

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 11, 2011 @ 10:24
    Dirk De Grave
    0

    there's two things to be aware of

    - for each member, the selected values from the checkbox list are stored in db in table cmsPropertyType (not sure whether it' stored as a comma separated string or as an xml fragment). Also be aware that values stored in db may be different than values stored in xml cache (id's vs values)

    - the possible values for the checkbox list (there's some static functions in the umbraco.library class that would return a list of possible values...)

     

    Hope this helps you getting started. But as mentioned on other post, try to find out whether those packages may be a good fit for your case.

     

    Cheers,

    /Dirk

  • 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