We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37032
    • 64 Posts
    Hello,

    I can't find any information or post about this issue so here it goes:

    How do I use &sortbyTV with a MIGX variable/value?

    [[!getResources?
        &parents=`0`
        &showHidden=`1`
        &tvFilters=`eventToggle==1`
        &limit=`0`
        &sortbyTV=`what to write here?`
        &sortdirTV=`ASC`
        &sortbyTVType=`datetime`
        &includeTVs=`1`
        &processTVs=`1`
        &tvPrefix=``
        &tpl=`modCalItem`
    ]]


    [
    	{
    		"caption": "Time & Place",
    		"fields": [
    			{
    				"field": "eventDateStart",
    				"caption": "Start date",
    				"inputTV": "inputDate"
    			},
    			{
    		    	"field": "eventDateEnd",
    		    	"caption": "End date",
    		    	"inputTV": "inputDate"
    		    }
    		]
    	}
    ]


    Let's say I would sort by "eventDateStart" for example.

    As it is today I can get sort the start date inside each returned resource with &sort inside the MIGX call but I need to be able to sort the full output.

    TIA [ed. note: tomahl last edited this post 14 years ago.]
      • 4172
      • 5,888 Posts
      you can't use &sortbyTV to sort by one of the MIGX-fields.

      while you could collect all MIGX-records of all MIGX-TVs and create a sorted resource-id-list for getResources, I think this isn't the best option.

      I think, it would be better to store all events in a custom-table and use a MIGXdb-TV to manage them.
      Then its easy to sort them by date and pull with the same query all connected resources.

        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 37032
        • 64 Posts
        Quote from: Bruno17 at Oct 10, 2012, 09:57 AM
        you can't use &sortbyTV to sort by one of the MIGX-fields.

        while you could collect all MIGX-records of all MIGX-TVs and create a sorted resource-id-list for getResources, I think this isn't the best option.

        I think, it would be better to store all events in a custom-table and use a MIGXdb-TV to manage them.
        Then its easy to sort them by date and pull with the same query all connected resources.


        Thanks for your reply.

        I'm not a system developer and for me the whole MIGXdb feels a bit complicated. Even when reading the documentation I feel kind of lost in that world.

        No plans to make getResources to read MIGX records? Would be really really handy. smiley
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          MIGx records are JSON-encoded strings. The string contains all the values of the entire MIGx TV for that resource. It would have to parse the JSON string for the MIGx field you're interested in, and while it's easy enough to do, getResources is big enough without adding that. You could make a custom snippet to get the MIGx JSON string and parse it, returning the value of the desired MIGx field, then use that snippet in the getResources property.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org