Skip to content

Instantly share code, notes, and snippets.

@zhabinka
Last active January 2, 2016 14:46
Show Gist options
  • Save zhabinka/a6c1a905614fa025c226 to your computer and use it in GitHub Desktop.
Save zhabinka/a6c1a905614fa025c226 to your computer and use it in GitHub Desktop.
Вывод документов с определённым значением TV.
<?php
$tvs = $modx->getCollection('modTemplateVarResource', array('tmplvarid' => 2, 'value' => 1));
if (count($tvs) > 4) return 'Найдено больше 4 документов';
foreach ($tvs as $tv) {
$res = $tv->getOne('Resource');
$output .= '<p><b>' .$res->get('pagetitle'). '.</b> ' .$res->get('introtext'). ' (' .$res->get('publishedon'). ')</p>';
}
return $output;
@zhabinka
Copy link
Author

zhabinka commented Jan 2, 2016

  1. Корявый вариант.
  2. Вариант с использованием метода getTVValue.
  3. С использованием связей и метода getOne.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment