<?php
$path = MODX_CORE_PATH . 'components/aeiproducts/';
$result = $modx->addPackage('aeiproducts',$path .
'model/','aei_');
if (! $result) {
return 'failed to add package';
}
$products = $modx->getCollection('Product');
foreach($products as $product) {
$fields = $product->toArray();
$output .= $modx->getChunk('ShowProds', $fields);
}
return $output;
?>$modx->runSnippet('FeetInch');
$fi = new FeetInch($modx,$scriptProperties);$output .= $fi->dec2inch(3.25) .'<br/>';
$products = $modx->getCollection('Product');
foreach($products as $product) {
$width = $product->get('width');
$nwWidth = $fi->dec2inch($width);
$output .= $nwWidth .'<br/>'; // Testing if the conversion works
$fields = $product->toArray();
$output .= $modx->getChunk('ShowProds', $fields);
}This question has been answered by opengeek. See the first response.
[[+field1:FeetInch]]
I would create a custom Output Modifier for this. Then you could just have something like this in your chunkI checked the link but can't figure out how to make a custom Output Modifier. Could you help me getting started?
[[+field1:FeetInch]]
<?php
$feetinch_base = $modx->getOption('feetinch.core_path',$scriptProperties,$modx->getOption('core_path').'components/feetinch/');
include_once $feetinch_base.'feetinch.class.php';
if (!$modx->loadClass('FeetInch',$feetinch_base,true,true)) {
return 'error: FeetInch class not found';
}
return '';$fi = new FeetInch($modx,$scriptProperties);
$output = $fi->dec2inch()
$output .= $modx->getChunk('ShowProds', array_merge($fields, array('nwWidth' => $nwWidth)));All you need is to include your calculated value in the properties you are passing to getChunk:That works perfectly
$output .= $modx->getChunk('ShowProds', array_merge($fields, array('nwWidth' => $nwWidth)));