Answer the question
In order to leave comments, you need to log in
How to set converting tv field in snippet?
There is a snippet that takes the price for sorting, the price is in euros and it needs to be converted to another currency, how can this be done with the price field in this snippet ?
$key_placeholder = 'show_block';
$modx->unsetPlaceholders($key_placeholder);
$params = array(
'parents' => $id,
'includeTVs' => 'price,power,overclocking,fuel_consumption,body_type,fuel_type,number_of_doors,rwd,transmission',
'select' => 'id,pagetitle',
'limit' => '20',
'depth' => '2',
'returnIds' => '1'
);
$where = array();
if(isset($_GET['price-from']) && isset($_GET['price-to'])) {
$where[] = 'price >= ' . $_GET['price-from'];
$where[] = 'price <= ' . $_GET['price-to'];
}
$where[] = 'template = 12';
$childrens = array();
$params['where'] = '["' . implode(' AND ', $where) . '"]';
$output = $modx->runSnippet('pdoResources', $params);
if (!empty($output)) {
$childrens = explode(',', $output);
foreach($childrens as $child_id) {
$all_childrens = $modx->getParentIds($child_id, 2, array());
$id_series = array_pop($all_childrens);
if ($id_series == $id) {
return $modx->setPlaceholders(array(
$key_placeholder => 1,
'child_id' => $child_id
));
}
}
return $modx->setPlaceholders(array(
$key_placeholder => 0
));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question