Copied to clipboard

Flag this post as spam?

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


  • FarmFreshCode 225 posts 422 karma points
    Apr 21, 2011 @ 19:09
    FarmFreshCode
    0

    Dropdown List - with specific values

    Hello Everyone,

    I would like to create is a dropdown list datatype where the editors see a list of locations like this:

    • Student Union
    • Admissions
    • College of Buisness

    But the actual value of those items are URLs that I can then use in my template like this:

    The editors don't need to be bothered with reading the whole URLs, but I haven't seen a datatype where I can enter both pieces of information. Any suggestions?

  • Berto 105 posts 177 karma points
    Apr 21, 2011 @ 19:23
    Berto
    1

    Hi,

    Try the Ultimate Picker (default of umbraco). You have to say the id of the container node that will have the "values".

    The Folder Drops have the nodes that I wan't on the dropdown on the "Post With drops" (pic)

    In the data type i just putted the node id of "Drops" node.

    Hope that this help

  • jeffreypriebe 4 posts 29 karma points
    Apr 21, 2011 @ 19:43
    jeffreypriebe
    0

    The ultimate picker could certainly work. To flesh out Berto's idea further:

    You'd create a Document Type to match the "schema" of your data. E.g.: "Location" with 2 textstring fields for Title + URL (or just one for URL and use the @nodeName for the "title value").

    You also likely want to create a Document Type to "contain" these in the Content area. E.g. "Locations" - no new properties, keep the Folder icon and give it "structure" to allow children of type "Location".

    Then decide where you want to place these Locations. Two good places might be: "at the root level" or "under the home node" (I'd do the first one). If you choose to put them under the home node: for Home, give it structure to allow "Locations" as a child.

    Ok, setup done; now for some content:

    Create a "Locations" folder in the content area (top level? - "sibling" to Home). Then create your three values - inserting the values that you want.

    Back to the ultimate picker: The Parent NodeID would be the "Locations" ID (can be seen in the Properties tab of Locations on the content-side).

     

    OR... alternate (if you don't need to allow the values to be updated):

    DataType: you create a dropdown - and populate it with the Titles/Names.

    When you go to insert the URL values (e.g. in a XSLT macro) - you have the "mapping" of Title/Name to URL there.

    Simpler and quicker, but not as easily maitained (and not recommended if you want the end-users to be able to manage the list).

     

    Make sense?

  • FarmFreshCode 225 posts 422 karma points
    Apr 21, 2011 @ 20:03
    FarmFreshCode
    0

    Thanks for the suggestion and explanation guys! I think I let a little confusion by not specifying that if an editor selects "Student Union" that would allow my template to use the external URL that I have assigned to be connected with that Title.

    My goal here was to add a location dropdown list for my blog admin area. This way an editor could write up a blog post (say about an event happening at the Student Union) and could easily select the building that the event is taking place. This would inturn provide me with the pre-determined googlemaps URL that I have already included for that building. This would ultimately provide me of a way to post links at the bottom of the blog post that say.."click here to get directions" (if they are needed).

    I know I could just add a text field for them to drop a google map URL in there themselves but I thought that if I did all the work for them, that I could make sure that they are using all the specific maps and coordinates that I want them to.

    That all being said, is jeffreypriebe's concept of the dropdownlist with macro mapping the best option? If so, do you think you could provide an example piece?

  • Berto 105 posts 177 karma points
    Apr 21, 2011 @ 20:49
    Berto
    0

    For me (it's a personal choice) i prefer the picker instead of the DropDown data type, because and quoting  jeffreypriebe not as easily maitained.

    Now, let see if i get it right. You wan't to have a list of location's, that have 2 properties, Name and GeoLocation, right?

    Them, for me, i would go for the ultimate picker, why? Beacause on the "Location" document type i would have two properties, Name (Textstring) and GeoLocation (Google Map Data Type - this is also a default of umbraco for the 4.7  i think). So you have on the backoffice the a google maps where you can set location on the google maps and an easy way to maintain the values.

    This pic is an example of google data type (with some more fields):

    You can see the site result in here

    http://www.grupoentreposto.pt/en/contacts

    I hope that this help...

  • FarmFreshCode 225 posts 422 karma points
    Apr 21, 2011 @ 21:22
    FarmFreshCode
    0

    @Berto Thats a beautiful page! nicely done. Well your example is a nice one. But more work than I would really need to do myself. We actually have a massive google map created for our campus area with all the buildings labeled, coordinates and other features like parking areas already included. Each building on our giant google map has a specific URL that you can go directly to if you would like and get detailed info on that building. (example: http://maps.mywebsite.com/student-union or http://maps.mywebsite.com/college-of-business).

    Since the number of buildings are of a limited nature, I dont have a problem with going in there and saying:
    Title of DropItem              Value for my template
    Student Union =>               http://maps.mywebsite.com/student-union
    College of Business =>       http://maps.mywebsite.com/college-of-business
    (just not sure how to do it properly)

    It will be a little time consuming upfront to match them up, but this way they will be linked to the offical map for our college. This map will contain all of the latest information about the buildings, contact info, and pictures (info that I dont want to replicate). So once I link it over to them, I wont have to worry about updating info, AND I get to take advantage of all their neat little additional features.

  • Berto 105 posts 177 karma points
    Apr 21, 2011 @ 21:44
    Berto
    0

    Thx!!!

    So, i've made an example using the DropDown Data type:

    The pictures above are the configuration of the datatype, the configuration of the property in the document type and the result in the editing of the node content

    This is the xslt

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
      <p>The value of the drop is :<xsl:value-of select="$currentPage/farmFreshCodeDropDown" /></p>
      
      <!-- In here you have to the mapping -->
      <xsl:choose>
        <xsl:when test="$currentPage/farmFreshCodeDropDown = 'Student Union'">
          <!-- Do what you want when its Student Union -->
          <p>So you wan't to go to Student Union</p>
        </xsl:when>
        <xsl:when test="$currentPage/farmFreshCodeDropDown = 'College of Business'">
          <!-- Do what you want when its College of Business -->
          <p>Ah, you prefer the College of Business</p>
        </xsl:when>    
        <xsl:otherwise>
          <!-- Do what you want when its none of the above -->
          <p>None chosen</p>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>

     

    And the end result:

    http://umbracoteste.itsmassive.com/page-1/post-folder/post-with-drops


  • FarmFreshCode 225 posts 422 karma points
    Apr 21, 2011 @ 22:18
    FarmFreshCode
    0

    @Berto Thank you! I think this is going to be my solution. I really appreciate the screenshots too! I am brand new to Umbraco and even finding basic stuff can sometimes cause me problems as I learn my way around the CMS and it's always nice to have a visual aid.

Please Sign in or register to post replies

Write your reply to:

Draft