Copied to clipboard

Flag this post as spam?

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


  • psiho 101 posts 96 karma points
    May 06, 2011 @ 12:26
    psiho
    0

    prevalues Xpath

    I'm trying to find some examples of Xpath used to select prevalues. "use current page as root" is almost enough for me but I need to filter out child nodes of current page based on some values. I'm hoping to be able to do it with Xpath but nothing seems to return anything.

  • psiho 101 posts 96 karma points
    May 06, 2011 @ 13:27
    psiho
    0

    I just realised it expects @id of the root node as a result of XPath. I was hoping it expects nodes to be used as prevalues. This is because i need to FILTER those nodes and this way... I don't think it is possible to filter.

    Anybody has an idea how to achieve this?

  • psiho 101 posts 96 karma points
    May 06, 2011 @ 17:06
    psiho
    0

    Well, we solved it and here is the followup if anybody needs it. At the end we extended contour with custom prevalue source type. It is exactly the same prevalue source type as built-in "document" but we replaced "document type" dropdown with Xpath textbox. So, once you choose root node ... you can filter children of that node (by Xpath) to create prevalues.

    This kind of looks like a good idea for the core module too since it is such a small change and very much like feature offered above for root node ("choose OR Xpath").

  • Comment author was deleted

    May 09, 2011 @ 08:17

    Awesome, yes would be good to include this, so instead of just selecting the parent with xpath you can also provide an xpath to select the nodes

  • psiho 101 posts 96 karma points
    May 25, 2011 @ 23:01
    psiho
    0

    justa a short followup... another issue appeared from this. It seems umbraco uses @nodeName to populate prevalues. On the other hand, when form is filled and saved, daat stored is not @nodeName but content of selected node. So, if that node has many properties, resulting value got by using umbraco.contour:GetRecord() really has a mess of data.

    On the other hand, when listing entries in back office of contour, there is @nodeName again. Maybe it is an issue with out modification of prevalues?

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jan 25, 2013 @ 22:23
    Jason Prothero
    0

    Tim,

    Does Contour 3.x allow for this scenario?  Is there a way to pick prevalues based on an XPATH expression?

     

    Mainly I just want a way to pick content that isn't a child but a decendent.  Think of content in an auto-folder scenario where the alphabetical folders contain the content I want to pick in my drop down.

     

    Thanks,
    Jason 

  • Comment author was deleted

    Jan 27, 2013 @ 18:25

    Hi Jason,

    Yes there is an Umbraco Documents prevalua source type that allows entering an xpath to select the parent node of the children you want to display.

    Don't think it works with grandchildren but can make an update :) so it is possible

  • Comment author was deleted

    Jan 28, 2013 @ 09:44

    Yup just checked the code and it only does children, will update with an option to move deeper

  • Comment author was deleted

    Jan 28, 2013 @ 09:51

    Issue created and set to 3.0.7 release :) http://issues.umbraco.org/issue/CON-227

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jan 28, 2013 @ 17:16
    Jason Prothero
    0

    Awesome Tim!

    I'll be watching for that release to come out and test it.

     

    -Jason

  • Jason Prothero 422 posts 1243 karma points c-trib
    Jan 28, 2013 @ 17:44
    Jason Prothero
    0

    Will the grandchildren change work with the simple node picker as well?

     

    Thanks,

    Jason

  • Comment author was deleted

    Jan 28, 2013 @ 17:45

    Yup that's the plan :) eta this week 

  • Comment author was deleted

    Feb 04, 2013 @ 12:39

    A bit delayed but haven't forgotten, will be part of 3.0.7 coming later today

  • Jason Prothero 422 posts 1243 karma points c-trib
    Feb 13, 2013 @ 06:02
    Jason Prothero
    0

    Tim,

    The fast turnaround on this is epic.  Thanks!

    I have one idea to take it further:

    Currently, it works great in the scenario you have above.  I get all my grandchildren and that will work.  However, I was thinking it might be nice if it integrated with the Document Type dropdown selection to act as a filter.  

    For example, given this Content structure:

    * A
      - Apple
      - Anise
    * B
      - Bok Choy

    Where A and B are Folder DocTypes and their children are Produce DocType.

    Could I set the Document Type drop down to Produce and then have the prevalue list be:

    Apple
    Anise
    Bok Choy

     

    That would be awesome.

     

    Anyways, thanks for a great package Tim!

     

    -Jason 

  • Comment author was deleted

    Feb 13, 2013 @ 08:24

    Sure makes more sense that way, will give it a shot

  • Comment author was deleted

    Feb 13, 2013 @ 14:38

    @Jason got a present for you :)

    https://dl.dropbox.com/u/886345/Contour.AddonsForProWorks.zip just unzip and place in your bin dir

    It's a new prevalue source that allows you to specify the nodes you want to include with an xpath expression 

    That should definlty do the trick for your scenario and a lot more... :)

  • Comment author was deleted

    Feb 13, 2013 @ 14:47

    Pretty easy to create btw, using uquery 

        public class XPathPrevalueSource: FieldPreValueSourceType 
        {
            [Setting("XPath", description = "Xpath to use", control = "Umbraco.Forms.Core.FieldSetting.TextField")]
            public string XPath { get; set; }
    
            public XPathPrevalueSource()
            {
                this.Id = new Guid("74B9D0CE-F12C-499D-9E04-B1847336207F");
                this.Name = "Umbraco Docs from xpath";
                this.Description = "Uses nodes found by xpath";
            }
    
            public override List<PreValue> GetPreValues(Field field)
            {
                return uQuery.GetNodesByXPath(XPath).Select(node => new PreValue {Id = node.Id, Value = node.Name}).ToList();
            }
    
            public override List<Exception> ValidateSettings()
            {
                return new List<Exception>();
            }
        }
  • Jason Prothero 422 posts 1243 karma points c-trib
    Feb 13, 2013 @ 19:27
    Jason Prothero
    0

    Tim,

    #h5yr doesn't really do this justice.  Beers at CodeGarden this year on me!

     

    It worked perfectly!  It even created the content on submission and linked to the node correctly.  Sweet!

     

    Thanks again for being awesome.


    -Jason 

Please Sign in or register to post replies

Write your reply to:

Draft