[Solved (sort of)] Cataloger module - Printable Catalog returns no results

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
stopsatgreen
Power Poster
Power Poster
Posts: 322
Joined: Sat Feb 04, 2006 1:24 am

[Solved (sort of)] Cataloger module - Printable Catalog returns no results

Post by stopsatgreen »

OK, I think I've got to grips with the Cataloger module except for one thing; I can't get the Printable Catalog page to work.

As far as I understand it, all I need to do is create a page with content type Catalog (Printable) and the default template should output all your items.

However, on my page nothing between the {section}{/section} tags is output.

Am I missing something?
Last edited by stopsatgreen on Tue Oct 02, 2007 11:14 am, edited 1 time in total.
alby

Re: Cataloger module - Printable Catalog returns no results

Post by alby »

stopsatgreen wrote: OK, I think I've got to grips with the Cataloger module except for one thing; I can't get the Printable Catalog page to work.

As far as I understand it, all I need to do is create a page with content type Catalog (Printable) and the default template should output all your items.

However, on my page nothing between the {section}{/section} tags is output.

Am I missing something?
Check variable with:
{$variable|print_r}

Alby
stopsatgreen
Power Poster
Power Poster
Posts: 322
Joined: Sat Feb 04, 2006 1:24 am

Re: Cataloger module - Printable Catalog returns no results

Post by stopsatgreen »

The items should be listed in the array $items; when I use $items.print_r it returns 'Array'. When I use $items|@print it returns 0. In my catalog so far I have one category and two items, so it should be returning something, right?

Any idea what I'm missing?
alby

Re: Cataloger module - Printable Catalog returns no results

Post by alby »

stopsatgreen wrote: The items should be listed in the array $items; when I use $items.print_r it returns 'Array'. When I use $items|@print it returns 0. In my catalog so far I have one category and two items, so it should be returning something, right?

Any idea what I'm missing?
There is a bug. $content is empty always

Code: Select all

  function & getAllContent()
    {
      global $gCms;
      $content = array();
      $hm =& $gCms->GetHierarchyManager();

      $rn = $hm->GetRootNode();
      $count = 0;
      $hm->getFlattenedChildren($rn, $content, $count);
      return $content;
    }
Fill a bug in forge tracker

Alby
stopsatgreen
Power Poster
Power Poster
Posts: 322
Joined: Sat Feb 04, 2006 1:24 am

Re: Cataloger module - Printable Catalog returns no results

Post by stopsatgreen »

I've filed this as a bug; fingers crossed someone addresses it soon, as I'm working on a project which needs this functionality.

Thanks for your help.
Duketown

Re: [Solved (sort of)] Cataloger module - Printable Catalog returns no results

Post by Duketown »

stopsatgreen, alby,

I did some digging and found the following:
alby noted that $content is always empty. Based upon this I searched internet for getFlattenedChildren. One of the results was:
http://trac.cmsmadesimple.org/cgi-bin/trac.cgi/changeset/2430?format=diff&new=2430.
Now there it showed a totally different detail of the function getFlattenedChildren. This function is part of the class Tree. This can be found in ..\lib\Tree\Tree.php on lines 215-218:

Code: Select all

	function &getFlattenedChildren()
	{
		return $this->nodes->getFlatList();
	}
I changed the function with the part found in the trac result. So I commented out lines 215-218 and inserted the found part, which results in:

Code: Select all

/*	function &getFlattenedChildren()
	{
		return $this->nodes->getFlatList();
	}
*/
	function getFlattenedChildren(&$parentnode, &$nodelist, &$count)
	{
        $children =& $parentnode->getChildren();
        if (isset($children) && count($children))
        {
            reset($children);
            while (list($key) = each($children))
            {
                $onechild =& $children[$key];
                $content =& $onechild->GetContent();
				$content->flatIndex = $count;
				array_push($nodelist, $content);
				$count++;
				$this->getFlattenedChildren($onechild, $nodelist, $count);
			}
		}
	}
I saved the Tree.php source and only one error occured:
Fatal error: Call to a member function Alias() on a non-object in ..\modules\Cataloger\action.defaultprintable.php on line 45
Now this is an easy one:
Simply change curPage on line 47 in action.defaultprintable.php into thisPage:

Code: Select all

$this->imageSpec($curPage->Alias(), 'p', 1, $printThumbSize);
into:
$this->imageSpec($thisPage->Alias(), 'p', 1, $printThumbSize);
I tested this on a 1.0.8 version. Brilliant.
I tested this in another site that runs on 1.1.2. Brilliant.
Well brilliant, I'm not that happy about the layout, but that is now a minor thing.

Are you able to test this, since Tree.php forms part of the core I would say.

Duketown
stopsatgreen
Power Poster
Power Poster
Posts: 322
Joined: Sat Feb 04, 2006 1:24 am

Re: [Solved (sort of)] Cataloger module - Printable Catalog returns no results

Post by stopsatgreen »

That seems to have done the trick! Tested on 1.2, seems fine apart from one weird behaviour: if you use a template with more then one {content} area, the list outputs in all of them.

Now that it's working, there are more bugs to report...
Last edited by stopsatgreen on Sun Nov 25, 2007 11:23 pm, edited 1 time in total.
Post Reply

Return to “CMSMS Core”