[Solved] MLE-Fork - Cataloger - Add Item/Category Resume to categorypage

This is a FORK of the CMS Made Simple project and is not oficially supported in any way by the CMS Made Simple development team.
Locked
hematec
New Member
New Member
Posts: 8
Joined: Fri Jun 20, 2008 10:49 am

[Solved] MLE-Fork - Cataloger - Add Item/Category Resume to categorypage

Post by hematec »

Hi @all,

i recently started playing around with cmsms and i'm really impressed. So big thanks to all developers!!!
But now i run into some difficulties with the cataloger module:

I really need to show a short summary of the category/item on the category page of the cataloger!

AFAIK there isn't a tag that provides this function - is it?

I added a userfield "resume" to the category and items.
I also took a look into the php code of the module but couldn't really get far with it.

Is there a  simple way to add this summaries to the categorypage or if not could someone point me to the right direction to realize this feature hardcoded in the module?
I'm a bit similar to php and added some aditional information to the items-list ( at "getCatalogItemsList"), but even with the api-doc i couldn't imagine how to add this "resume" content to an item in the items-list.

Many thanx in advance for your help!!
Cheers, hematec
Last edited by hematec on Fri Jun 27, 2008 3:48 pm, edited 1 time in total.
hematec
New Member
New Member
Posts: 8
Joined: Fri Jun 20, 2008 10:49 am

Re: [Solved] MLE-Fork - Cataloger - Add Item/Category Resume to categorypage

Post by hematec »

OK forgot to say i use the MLE fork!

Normaly you can access the attributes of an item by

Code: Select all

{$items[].[i]attrName[/i]}
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
alby

Re: [Solved] MLE-Fork - Cataloger - Add Item/Category Resume to categorypage

Post by alby »

If someone confirms, we can create a topic (and sticky) with patchs of various modules

Alby
steven_germany
Forum Members
Forum Members
Posts: 34
Joined: Tue Apr 21, 2009 6:52 pm

Re: [Solved] MLE-Fork - Cataloger - Add Item/Category Resume to categorypage

Post by steven_germany »

yes - works fine for me ...
Locked

Return to “[locked] CMSMS MLE fork”