Page 1 of 1

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

Posted: Mon Oct 01, 2007 10:30 pm
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?

Re: Cataloger module - Printable Catalog returns no results

Posted: Tue Oct 02, 2007 7:31 am
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

Re: Cataloger module - Printable Catalog returns no results

Posted: Tue Oct 02, 2007 8:44 am
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?

Re: Cataloger module - Printable Catalog returns no results

Posted: Tue Oct 02, 2007 10:19 am
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

Re: Cataloger module - Printable Catalog returns no results

Posted: Tue Oct 02, 2007 11:13 am
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.

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

Posted: Sun Nov 25, 2007 9:05 pm
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

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

Posted: Sun Nov 25, 2007 11:19 pm
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...