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

    how can I sort with getResources by a template variable?

    I try this:
     [[getResources? &parents=`31` &tpl=`tplStatusB` &includeTVs=`1` &sortby=`docCount` &limit=`25`]]
    

    I get a error:
    (ERROR @ /index.php) Error 42S22 executing statement: Array ( [0] => 42S22 [1] => 1054 [2] => Unknown column ’docCount’ in ’order clause’ )

    If I try &sortby=`tv.docCount` there will be the same error
      • 8694
      • 61 Posts
      Hello,

      is there nobody with any sugestions about this?
        • 28215
        • 4,149 Posts
        getResources does not support sorting by TVs at this time.
          shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
          • 30224
          • 11 Posts
          Anyone know if there IS a tag for sorting the results from getResources? It would be nice to be able to sort alphabetically by longtitle or other field.
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: Green at Sep 23, 2010, 11:35 AM

            Anyone know if there IS a tag for sorting the results from getResources? It would be nice to be able to sort alphabetically by longtitle or other field.
            The current sortby parameter supports any field on the Resource class (the site_content table).
            &sortby=`longtitle` &sortdir=`ASC`
            will sort by the longtitle in ascending order.
              • 19534
              • 183 Posts
              Quote from: splittingred at Aug 12, 2010, 11:36 AM

              getResources does not support sorting by TVs at this time.

              FYI: now it does!
                Add-On to easily manage your multilingual sites: Babel
                • 21295
                • 22 Posts
                I tried to sort by a TV but I wasn’t able, any idea what am I doing wrong?

                Thx smiley

                this was my call
                [[!getResources? &parents=`[[*id]]` &processTVs=`1` &includeTVs=`1` &tvPrefix=`` &tpl=`mencioncall` &showHidden=`1` &sortby=`fecha`]]
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: Neutron at Nov 07, 2010, 05:20 AM

                  I tried to sort by a TV but I wasn’t able, any idea what am I doing wrong?

                  Thx smiley

                  this was my call
                  [[!getResources? &parents=`[[*id]]` &processTVs=`1` &includeTVs=`1` &tvPrefix=`` &tpl=`mencioncall` &showHidden=`1` &sortby=`fecha`]]
                  Yes, sorting by TV’s requires the use of the sortbyTV (and sortdirTV) property, not the sortby (or sortdir) property.
                    • 23114
                    • 1 Posts
                    Thanks for the great extension jason, it’s been super useful! One question I can’t seem to solve - is there any way to pass a group of resources into get resources and not sort them at all - meaning display them in the order they were already in. I’m putting some jquery on the front page of our site that shows featured items, most recent items, and highest rated items. featured and most recent are working beautifully, but the highest rated info is stored in a table that is not the main modx_site_content table within the db. And so I am passing the results of a query rows into get resources using a $HighestRatedGameIds array variable but would like it not to resort them by the publishedon field (or any other field for that matter). The code looks like this:

                    $highestRatedGameIds = "";
                    				$stmt = $modx->query("SELECT star_id FROM modx_star_rating ORDER BY vote_total DESC");
                    				if ($stmt) {
                    					while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
                    						$highestRatedGameIds .= $row['star_id'] . ",";
                    					}
                    				}
                    
                    				$getResourceParams = array(
                    		                'tpl'=>'sidebar_item_game',
                    		                'resources'=>$highestRatedGameIds,
                    				'includeTVs'=>1,
                    		                'processTVs'=>1,
                    		                'tvPrefix'=>'tv_',
                    		       		 );
                    
                    		        $output .= $modx->runSnippet('getResources', $getResourceParams);


                    Is it possible to make getResources not sort these, or to sort by a column in a table other than modx_site_content? Thanks a ton!