Skip to content

Instantly share code, notes, and snippets.

@goldsky
Created December 24, 2013 08:47
Show Gist options
  • Select an option

  • Save goldsky/8110511 to your computer and use it in GitHub Desktop.

Select an option

Save goldsky/8110511 to your computer and use it in GitHub Desktop.
Count how many resources which have specified TV that has specified value
<?php
$name = $modx->getOption('name', $scriptProperties);
$value = $modx->getOption('value', $scriptProperties);
if (empty($tvName) || empty($value)) {
return;
}
$tvObj = $modx->getObject('modTemplateVar', array(
'name' => $name
));
if (!$tvObj) {
return;
}
$tv2Res = $tvObj->getMany('TemplateVarResources', array(
'value:LIKE' => "%$value%"
));
return count($tv2Res);
@goldsky

goldsky commented Dec 24, 2013

Copy link
Copy Markdown
Author

[[tvCounter? &name=product-category &value=accessories]]

@adamwintle

Copy link
Copy Markdown

Unfortunately I can't get this working - how have you setup your TV?

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