Giter Site home page Giter Site logo

custom sort option about pdotools HOT 10 CLOSED

modx-pro avatar modx-pro commented on September 3, 2024
custom sort option

from pdotools.

Comments (10)

bezumkin avatar bezumkin commented on September 3, 2024

Just specify &sortby=``

from pdotools.

paulbohman avatar paulbohman commented on September 3, 2024

That may work if I am sorting by a field, but it does not work if I need to sort them in the exact order that I specify in my call in the snippet. How do I get them in this exact order?
99,748,443,1086
I can't sort by id. I can't sort by pagetitle. I can't sort by longtitle. What do I sort by?

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

You do not understand me. You need specify not empty &resources and empty &sortby.

[[!pdoMenu?
    &parents=`0`
    &resources=`1,2,25,68`
    &sortby=``
    &showLog=`1`
]]

http://yadi.sk/d/P4doJMcgK6JnF

from pdotools.

exside avatar exside commented on September 3, 2024

hm, could it be that your example works "as expected" as your resources are basically in the order they would be anyways (eg. ASC ids)? I remember that disussion: https://github.com/bezumkin/pdoTools/issues/26

where the outcome was

&sortby=`FIELD(modResource.id, "392,230,538,476,210,530,110,209,118,84,228,229")`

from pdotools.

paulbohman avatar paulbohman commented on September 3, 2024

exside: my resources were almost in the order of ascending IDs, but one of them was out of place.
bezumkin: Yes, sortby=`` (empty value between the backticks) did work. Thank you.

I would not have expected that to be the method though. I would have expected the default order to be the order that I specified in the &resources parameter. Wayfinder uses that order. Now that I know how it works, I can do it, but it would be more intuitive to use the order I specified without having to also specify an empty sort string.

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

pdoMenu already has default sort by menuindex, that is why you need to specify empty &sortby

And you can continue using more intuitive Wayfinder, if you like it.

from pdotools.

paulbohman avatar paulbohman commented on September 3, 2024

pdoMenu is much faster than Wayfinder. I stopped using Wayfinder as soon as I found pdoMenu. I don't mean to say that I prefer Wayfinder, because I don't. Your software is better. And I agree that menuindex is the best field for the default sort order. Wayfinder does that too. In the specific instance of specifying exact IDs, though, Wayfinder will use the order I list them, without having to specify a separate parameter for the sort order. When specifying exact IDs, the IDs might be in several different containers/folders, so the menuindex is not a reliable method of sorting. Menuindex is reliable only when the items are in the same container/folder.

from pdotools.

bezumkin avatar bezumkin commented on September 3, 2024

pdoMenu is based on pdoTools library, that has many features.

You can specify the only needed ids of resources in query, but sort them by publishedon field, or menuindex. Why I need to force your sorting decision?

The same rules works in pdoResources and other snippets - thanks to pdoTools.

from pdotools.

paulbohman avatar paulbohman commented on September 3, 2024

In additional testing, I've discovered that pdoMenu still does not order the menu items in the exact order that I need. If I have resources at different levels in the hierarchy, even if I use sortby=, pdoMenu seems to put all of the items at the top level first, then all of the items at the second level. So in this statement: [[pdoMenu? &parents=`0` &resources=`1,20,2,21` &sortby=]]
If 1 and 2 are at the top level, and 20 and 21 are at the second level, pdoMenu will display them in this order:
1,2,20,21
If I move resource 20 to the top level, then the pdoMenu will give me this order:
1,20,2,21
But I cannot get the desired order if 20 is on level 2.

from pdotools.

exside avatar exside commented on September 3, 2024

did you try

&sortby=`FIELD(modResource.id, "1,20,2,21")`

?

from pdotools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.