[daisy] Gettings contents of documentBasket on other pages
Vincent Mouton
vincent at postback.be
Wed May 2 07:38:16 CDT 2007
> On Sun, 2007-04-29 at 14:43 +0200, Vincent Mouton wrote:
> > Hello,
> >
> > I was wondering if there's a way (an ext for example) to get the
> contents of
> > the document basket on other pages of a site, besides the
> /documentBasket/**
> > pages.
> > I don't need the entire documents. The number of documents, or their
> > name/docId is enough.
> >
> > I know how to create an ext, but I can't seem to find a way to pull
> the
> > contents of the docbasket in.
> >
>
> Rather than going through the DocumentBasketApple, this approach might
> be simpler.
>
> Create some flowscript like this:
>
> importClass(Packages.org.outerj.daisy.frontend.components.docbasket.Doc
> umentBasketHelper);
>
> function showBasketSize() {
> // the false argument means the basket instance should not be created
> // if it does not exist yet
> var documentBasket =
> DocumentBasketHelper.getDocumentBasket(cocoon.request, false);
>
> var numberOfDocs = 0;
> if (documentBasket != null) {
> numberOfDocs = documentBasket.size();
> }
>
> // and then pass that to a pipeline through the viewData
> var viewData = {};
> viewData["documentBasketSize"] = numberOfDocs;
> sendPage("BasketSizePipe", viewData);
> }
>
> The sitemap could be something like this:
>
> <map:match pattern="basketSize">
> <map:call function="showBasketSize"/>
> </map:match>
>
> <map:match pattern="BasketSizePipe">
> <map:generate type="jx" src="page.xml"/>
> <map:serialize type="xml"/>
> </map:match/>
>
> and page.xml could look like:
>
> <div>
> Number of documents in basket: ${documentBasketSize}
> </div>
>
> Instead of passing just the size, you could of course pass the complete
> DocumentBasket object.
>
> I havn't tested any of the above, so there might be typos in there :-)
Bruno,
Thanks. This looks much more simple than my raw sitemap hacking.
And it also solved the issue I had with the basketAction parameter that was
missing.
Cheers,
v
More information about the daisy
mailing list