We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11316
    • 81 Posts
    Can’t seem to figure out how to make my TV as the sort by in a custom snippet. Any help would be greatly appreciated.

    $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;
      • 8548
      • 104 Posts
      Hello,

      did you find the solution? I trying to do the same thing with no result either sad

      cheers