OK forgot to say i use the MLE fork!
Normaly you can access the attributes of an item by
as descriped in the templatesystem.
But for using this in the MLE fork you have to patch the function
getCatalogItemsList in the
Cataloger.module.php!
Change the function as followed:
Code: Select all
function getCatalogItemsList(&$params)
{
global $gCms;
// Start MLE - added by hematec
global $hls, $hl;
// End MLE - added by hematec
$hm =& $gCms->GetHierarchyManager();
$lastcat = "";
if (isset($params['alias']) && $params['alias'] == '/')
{
$content = $hm->getFlatList();
$curHierDepth = isset($params['start_depth'])?$params['start_depth']:-1;
$curHierarchy = '';
$curHierLen = 0;
$curPage = new ContentBase();
}
else
{
if (isset($params['content_id']))
{
$curPageID = $gCms->variables[$params['content_id']];
$curPageNode = $hm->sureGetNodeById($curPageID);
$curPage = $curPageNode->GetContent();
}
else if (isset($params['alias']))
{
$curPageNode = $hm->sureGetNodeByAlias($params['alias']);
$curPage = $curPageNode->GetContent();
$curPageID = $curPage->Id();
}
else if (isset($gCms->variables['content_id']))
{
$curPageID = $gCms->variables['content_id'];
$curPageNode = $hm->sureGetNodeById($curPageID);
$curPage = $curPageNode->GetContent();
}
$curHierarchy = $curPage->Hierarchy();
$curHierLen = strlen($curHierarchy);
$curHierDepth = substr_count($curHierarchy,'.');
$content = $this->getSubContent($curPageID);
}
$categoryItems = array();
foreach ($content as $thisPage)
{
$thispagecontent = $thisPage->GetContent();
if ($thispagecontent === false)
{
continue;
}
if (method_exists($thispagecontent,'Active') && !$thispagecontent->Active())
{
continue;
}
if ($thispagecontent->Id() == $curPage->Id())
{
continue;
}
$type_ok = false;
$depth_ok = false;
if ($thispagecontent->Type() == 'contentalias')
{
//$curHierarchy = $thispagecontent->TargetHierarchy();
$thispagecontent = $thispagecontent->GetAliasContent();
$curHierLen = strlen($curHierarchy);
$curHierDepth = substr_count($curHierarchy,'.');
}
if ($thispagecontent->Type() == 'catalogcategory')
{
$lastcat = $thispagecontent->Name();
}
if ($thispagecontent->Type() == 'catalogitem' &&
($params['recurse'] == 'items_one' ||
$params['recurse'] == 'items_all' ||
$params['recurse'] == 'mixed_one' ||
$params['recurse'] == 'mixed_all'))
{
$type_ok = true;
}
else if ($thispagecontent->Type() == 'catalogcategory' &&
($params['recurse'] == 'categories_one' ||
$params['recurse'] == 'categories_all' ||
$params['recurse'] == 'mixed_one' ||
$params['recurse'] == 'mixed_all'))
{
$type_ok = true;
}
if (! $type_ok)
{
continue;
}
if (($params['recurse'] == 'items_one' ||
$params['recurse'] == 'categories_one' ||
$params['recurse'] == 'mixed_one') &&
substr_count($thispagecontent->Hierarchy(),'.') ==
($curHierDepth + 1) &&
substr($thispagecontent->Hierarchy(),0,$curHierLen+1) == $curHierarchy.'.')
{
$depth_ok = true;
}
else if ((isset($params['alias']) && $params['alias'] == '/') ||
(($params['recurse'] == 'items_all' ||
$params['recurse'] == 'categories_all' ||
$params['recurse'] == 'mixed_all') &&
substr($thispagecontent->Hierarchy(),0,$curHierLen+1) == $curHierarchy.'.'))
{
$depth_ok = true;
}
if (! $depth_ok)
{
continue;
}
// in the category, and approved for addition
$catThumbSize = $this->GetPreference('category_image_size_thumbnail',90);
$itemThumbSize = $this->GetPreference('item_image_size_category',70);
$missingImage = $this->GetPreference('show_missing','1');
switch ($thispagecontent->Type())
{
case 'catalogitem':
$thisItem['image'] = $this->imageSpec($thispagecontent->Alias(),
's', 1, $itemThumbSize);
$thisItem['image_src'] = $this->srcImageSpec($thispagecontent->Alias(),
1);
break;
case 'catalogcategory':
$thisItem['image'] = $this->imageSpec($thispagecontent->Alias(),
'ct', 1, $catThumbSize);
break;
}
$thisItem['link'] = $thispagecontent->GetUrl();
$thisItem['title'] = $thispagecontent->Name();
$thisItem['menutitle'] = $thispagecontent->MenuText();
$thisItem['modifieddate']=$thispagecontent->GetModifiedDate();
$thisItem['category']=$lastcat;
$thisItem['cat']=$lastcat;
$thisItem['createdate']=$thispagecontent->GetCreationDate();
$thisItem['type']=$thispagecontent->Type();
$theseAttrs = $thispagecontent->getAttrs();
foreach ($theseAttrs as $thisAttr)
{
$safeattr = strtolower(preg_replace('/\W/','',$thisAttr->attr));
// Start MLE - added by hematec
if(isset($hls))
{
// some kind of quick & dirty
$safeattr = substr($safeattr,0,-strlen($hl)-1); //$thisAttr->attr = $row['attribute']."_$hl";
}
// End MLE - added by hematec
$thisItem[$safeattr] = $thispagecontent->GetPropertyValue($thisAttr->attr);
}
array_push($categoryItems,$thisItem);
}
return array($curPage,$categoryItems);
}
Maybe someone could include this in the patchfiles for the MLE-fork?
I also added the line
Code: Select all
$thisItem['type']=$thispagecontent->Type();
to be able to gather the contenttype (catalogcategory,catalogitem,...).
If you don't need this simply remove this line.
Have fun with it,
hematec