Copied to clipboard

Flag this post as spam?

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


  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 16:27
    John C Scott
    0

    xpath example with xpath checkboxlist

    struggling to work out what the xpath expression should be

    under the root I have a content node called MetaData, with another called Years beneath it, and then a list of valid years the user can choose beneath that (eg 2007; 2008; 2009 etc) -

    i want the xpath checkbox list to list all these years 

    it will always be from the root

    any pointers? :)

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 02, 2012 @ 16:30
    Lee Kelleher
    0

    Hi John,

    Thinking it would be something like...

    descendant::MetaData/Years/*[@isDoc]

    Guessing the last part could be "Year"? ;-)

    Cheers, Lee.

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:04
    John C Scott
    0

    yep that is probably what i would have expected to work

    just checking...

    MetaData & Years these are my node names not my data types

    is there an easy way to debug this

    does the fact that they are in the absolute root cause any issue?

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 02, 2012 @ 17:08
    Lee Kelleher
    0

    Hi John,

    What are the aliases for the MetaData and Years document-types?  Guessing that they aren't the same as the node names?

    Thanks, Lee.

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:10
    John C Scott
    0

    XML in /appdata/umbraco.config looks like this

    </root>
    <MetaData id="1392" parentID="-1" level="1" writerID="5" creatorID="5" nodeType="1389" template="0" sortOrder="7" createDate="2012-05-02T11:36:52" updateDate="2012-05-02T12:17:52" nodeName="MetaData" urlName="metadata" writerName="johncscott" creatorName="johncscott" path="-1,1392" isDoc="">
      <MetaDataType id="1393" parentID="1392" level="2" writerID="5" creatorID="5" nodeType="1390" template="0" sortOrder="1" createDate="2012-05-02T11:37:20" updateDate="2012-05-02T12:17:54" nodeName="Years" urlName="years" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393" isDoc="">
        <MetaDataItem id="1394" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="1" createDate="2012-05-02T11:38:26" updateDate="2012-05-02T12:17:56" nodeName="2007" urlName="2007" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1394" isDoc="" />
        <MetaDataItem id="1395" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="2" createDate="2012-05-02T11:38:49" updateDate="2012-05-02T12:17:57" nodeName="2008" urlName="2008" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1395" isDoc="" />
        <MetaDataItem id="1396" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="3" createDate="2012-05-02T11:39:03" updateDate="2012-05-02T12:17:58" nodeName="2009" urlName="2009" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1396" isDoc="" />
        <MetaDataItem id="1397" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="4" createDate="2012-05-02T11:39:18" updateDate="2012-05-02T12:18:00" nodeName="2010" urlName="2010" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1397" isDoc="" />
        <MetaDataItem id="1398" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="5" createDate="2012-05-02T11:39:40" updateDate="2012-05-02T12:18:03" nodeName="2011" urlName="2011" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1398" isDoc="" />
        <MetaDataItem id="1399" parentID="1393" level="3" writerID="5" creatorID="5" nodeType="1391" template="0" sortOrder="6" createDate="2012-05-02T11:40:08" updateDate="2012-05-02T12:18:06" nodeName="2012" urlName="2012" writerName="johncscott" creatorName="johncscott" path="-1,1392,1393,1399" isDoc="" />
      </MetaDataType>
    </MetaData>
    </root> 

    Could it be some kind of reserved word issue?

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:12
    John C Scott
    0

    >What are the aliases for the MetaData and Years document-types?

    err one of them is 

    is that bad?


  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 02, 2012 @ 17:13
    Lee Kelleher
    1

    OK, let's try this...

    descendant::MetaData/MetaDataType/MetaDataItem

    Cheers, Lee.

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:15
    John C Scott
    0

    sorry will actually answer the question this time (a mans got to earn a little karma when he can!)

    So 

    NodeNameDocumentType

    MetaDataMetaData

    YearsMetaDataType

    2007; 2008MetaDataItem

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:19
    John C Scott
    0

    ahaaa - of course - i suspected i was being a bit daft - ooops

    presumably if i had more than one MetaDataType and I wanted to only have years

    it would be something like

    descendant::MetaData/MetaDataType[name()='Years']/MetaDataItem
  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 02, 2012 @ 17:21
    Lee Kelleher
    1

    Very close... small correction - change the "name()" to "@nodeName":

    descendant::MetaData/MetaDataType[@nodeName = 'Years']/MetaDataItem
  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:21
    John C Scott
    1

    or maybe

    descendant::MetaData/MetaDataType[@nodeName='Years']/MetaDataItem 

    name() obviously is totally wrong :-$

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 17:22
    John C Scott
    1

    if you ever decide to write "The Idiots Guide to XPATH in Umbraco"

    I know a good idiot you could test it on :D

  • Dan 1285 posts 3917 karma points c-trib
    May 02, 2012 @ 22:20
    Dan
    1

    Hi John,

    I saw your tweet from earlier today about the year range in the Umbraco date-picker datatype.  Not sure if this forum thread originated because you wanted to bypass that limitation, but I just wanted to chip in with a way to modify the year range in the built-in umbraco datatype as it's quite easy.

    Basically the calendar picker used by Umbraco is powered by jQuery UI.  So open up 'umbraco_client > ui > jqueryui.js' and find where it says:

    yearRange: "-10:+10"

    Just modify this to your requirements, e.g. "-100:0" if you're using it for date of birth.  You'll then probably need to delete the client dependency cache (App_Data > TEMP > ClientDependency) and restart your app pool, but that should then give you a more appropriate range.  It's worth noting, an Umbraco patch release requires that you overwrite the umbraco_client folder, so this hack will not persist across point releases.

    I'm not sure of the reason the range is so limited to begin with but I suspect it's just the default out-of-the-box jQuery UI range, to keep the drop-down neat.

    I have no idea if this helps you :)

    Dan

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 22:34
    John C Scott
    0

    Thanks Dan - that wasn't the reason - just that what i'm doing on this new project is a bit date focussed!

    However that's a brilliant solution.

    I suspect this could be your first package (that is unless I'm being rude and presumptious) happy to code it if you make me a collaborator :-p

    Actually though I am not sure if this is packagable - I'm not sure a package should overwrite the client folder. However there must be a simple way.

    Would be nice (and should be relatively easy) to make the date range configurable in the data type editor. I can see how a site focussing on dates of birth for a basketball junior league site could want different ranges to a history society.

    An experienced package developer may offer a solution. Maybe one who is too busy with their multifluous package developments... and wants to guide a youung grass-hopper :D

    Thanks though - even if none of the above works you've given me a great solution to the problem :)

    High 5! YOU ROCK!  :-p

     

     

  • John C Scott 473 posts 1183 karma points
    May 02, 2012 @ 22:42
    John C Scott
    0

    One other thing... and a desperate attempt to earn another karma point [they mean more to you when you have less :)  ]

    I installed the skiltz date picker package - and that was actually worse, in that you could only go back a year by clicking back 12 months

    So to get back to 13/1/1972 would have involved 12x40+4 clicks! The first entry I had to do was in 1959 so needless to say I didn't try it :)

     

    But there is a really nice implementation in it for setting the time with two sliders for hours and minutes.

    Three sliders to get century, decade, and final year digit would be really neat UI.

     

    Now I'm no front - end UI guru - but you are mine... so do you think that would be possible?

     

    Dammmit - you all just rock SO hard! :)

     

    [and thank you for all the help today too]

     

     

     

  • Lee Kelleher 4020 posts 15802 karma points MVP 13x admin c-trib
    May 03, 2012 @ 11:33
    Lee Kelleher
    1

    The thing with the date picker is that Umbraco already has done... on a content node, if you look at the "Publish at" / "Remove at" fields (on Properties tab), that control as a dropdown for the Years.  Not sure what the data-type version does, (I'll go check after this post).

    Either way, it wouldn't be difficult to create a new data-type based on this.

    Also, let's say, *if* there were a CodePlex ticket for it, it might even be fixed in the core? ;-)

    Cheers, Lee.

  • Dan 1285 posts 3917 karma points c-trib
    May 03, 2012 @ 11:47
    Dan
    1

    Ha-ha, I like your style Mr K!  http://umbraco.codeplex.com/workitem/30804

  • John C Scott 473 posts 1183 karma points
    May 03, 2012 @ 18:04
    John C Scott
    0

    voted too :)

Please Sign in or register to post replies

Write your reply to:

Draft