I have this situation:
CATEGORY 1
PRODUCT A
PRODUCT B
PRODUCT C
CATEGORY 2
PRODUCT D
PRODUCT A
CATEGORY 3
PRODUCT B
PRODUCT A
I want have a list of all products unique:
PRODUCT A
PRODUCT B
PRODUCT C
PRODUCT D
I try do this snippets:
<?php
/**
* getResourceUnique
*
* DESCRIPTION
*
* This Snippet select distinct resource by name.
*
* USAGE:
*
* [[!getResourceUnique? &tpl=`childItem-prodotti-row` ]]
*
*/
$limit = (isset($limit)) ? $limit : 10;
$showHidden = (isset($showHidden)) ? $showHidden : 1;
$featured = (isset($featured)) ? $featured : '';
$tpl = $modx->getOption('tpl',$scriptProperties,'childItem-prodotti-row');
$id = (int)$modx->getOption('id',$scriptProperties,17);
$c = $modx->newQuery('modResource');
$c->select('DISTINCT `modx_site_content`.`pagetitle`');
$c->where(array(
'published' => true,
'deleted' => false,
'hidemenu' => $showHidden,
'link_attributes' => $featured,
));
$children = $modx->getChildIds($id);
if (count($children) > 0) {
$c->where(array(
'id:IN' => $children,
));
}
$c->sortby('publishedon','DESC');
$resources = $modx->getCollection('modResource',$c);
//$resources = $modx->getIterator('modResource',$c);
$output = '';
var_dump($resources);
foreach($resources as $resource) {
$output .= '<br /> test' . $resource->get('pagetitle');
}
return $output;
But i recive this error:
[2015-11-26 09:53:09] (ERROR @ /index.php) Error 42S22 executing statement:
Array
(
[0] => 42S22
[1] => 1054
[2] => Unknown column 'modx_site_content.pagetitle' in 'field list'
)