<![CDATA[ Help with a custom sortby TV - My Forums]]> https://forums.modx.com/thread/?thread=31199 <![CDATA[Re: Help with a custom sortby TV]]> https://forums.modx.com/thread/31199/help-with-a-custom-sortby-tv#dis-post-545136
did you find the solution? I trying to do the same thing with no result either sad

cheers]]>
Egam Sep 19, 2016, 08:01 PM https://forums.modx.com/thread/31199/help-with-a-custom-sortby-tv#dis-post-545136
<![CDATA[Help with a custom sortby TV]]> https://forums.modx.com/thread/31199/help-with-a-custom-sortby-tv#dis-post-168808
$tvIdOne = 14;
$tvIdTwo = 28;

$c = $modx->newQuery('modResource');
$c->where(array(
   'parent:IN' => array(56,57,58,59,60,61,62,63),
   'deleted' => false,
   'hidemenu' => false,
   'published' => true,
));
/////// HELP! ///////
$tvSort = $modx->resource->getTVValue($tvIdTwo);
$c->sortby($tvSort,'ASC');
/////// HELP! ///////
$c->limit(40);
$resources = $modx->getCollection('modResource',$c);

$output = '';
$output .= '<div>';
foreach ($resources as $resource) {
	$tvValue = $resource->getTVValue($tvIdOne);
	$tvSort = $resource->getTVValue($tvIdTwo);
	if($tvValue =="none"){
		} else {
		$input = $tvValue;
		$width = 220;
		$height= 220;
		$options = "w=$width&h=$height"; 
		$thumbnail = $modx->runSnippet("phpthumbof",array('input' => $input, 'options' => $options));
		$output .= '<p>'.$tvSort.'</p><div class="thumb"><a title="'.$resource->get('pagetitle').'" href="'.$modx->makeUrl($resource->get('id')).'"><img alt="'.$resource->get('pagetitle').'" src="'.$thumbnail.'" height="142" width="220" /></a></div>';
	}
}
$output .= '<br clear="all" /></div>';
return $output;
]]>
gremlin May 04, 2011, 02:45 PM https://forums.modx.com/thread/31199/help-with-a-custom-sortby-tv#dis-post-168808