$c = $modx->newQuery('modTemplateVar','modTemplateVar'); $c->select('modMediaSource.properties'); $c->leftJoin('modMediaSource','modMediaSource','modMediaSource.id = modTemplateVar.source'); $c->where(array( 'modTemplateVar.name'=>'item-image' )); $props = $modx->getCollection('modTemplateVar',$c);
SELECT modMediaSource.properties FROM `site_tmplvars` AS `modTemplateVar` LEFT JOIN `media_sources` `modMediaSource` ON modMediaSource.id = modTemplateVar.source WHERE ( AND `modTemplateVar`.`name` = 'item-image' )
This question has been answered by multiple community members. See the first response.
$c = $modx->newQuery('modTemplateVar','modTemplateVar');
$c = $modx->newQuery('modTemplateVar');
SELECT MediaSource.properties FROM `media_sources` AS `MediaSource` LEFT JOIN `site_tmplvars` AS `modTemplateVar` ON MediaSource.id = modTemplateVar.source WHERE `modTemplateVar`.`name` = 'item-image'
$tv->getSource($context,false);
$tv = $modx->getObject('modTemplateVar', array('name' => 'item-image'));
$tvId = 12; /* replace with the ID of your item-image TV */ $tv = $modx->getObject('modTemplateVar', $tvId); $mediaSource = $tv->getSource($context,false);
if(!function_exists('cfGetImageBaseByTvName')){ function cfGetImageBaseByTvName($tvname,$rootrelative=false,$property='baseUrl',$context='web') { global $modx; $imagebase = ''; $tv = $modx->getObject('modTemplateVar', array('name' => $tvname)); if(!empty($tv)){ $imagebase = $tv->getSource($context,false)->get('properties')[$property]['value']; if(!empty($imagebase)){ $imagebase = $rootrelative ? '/'.str_replace('//', '/', $imagebase) : trim($imagebase,'/') ; } } else { $msg = 'Can not get object for tv named "'.$tvname.'". Look for typos in the tv name passed to this function.'; $modx->log(modX::LOG_LEVEL_ERROR, $msg,'','cfGetImageBaseByTvName',__FILE__,__LINE__); } return $imagebase; } }