Klortho schrieb:
Good stuff, thanks!  You gave me the general idea -- an internal redirect
with the parameter stuffed into the internal URL.  I had to change your code
a bit to get it to work, here's what I came up with:

Main sitemap:

    <!--
      The URL Z/index.html will either get served from the physical
directory
      A or B, depending on which is present.
    -->
      <map:match pattern='Z/*'>
        <map:select type='resource-exists'>
          <map:when test='A/sitemap.xmap'>
            <map:redirect-to uri='cocoon:/subsitemap-A/cyan/{1}'/>
          </map:when>
          <map:when test='B/sitemap.xmap'>
            <map:redirect-to uri='cocoon:/subsitemap-B/orange/{1}'/>
          </map:when>
          <map:otherwise>
          </map:otherwise>
        </map:select>
      </map:match>

      <map:match pattern='subsitemap-*/*/**'>
        <map:mount uri-prefix='subsitemap-{1}' src='{1}/sitemap.xmap'/>
      </map:match>

Sub-sitemap:

      <map:match pattern='*/index.html'>
        <map:generate src="index.xml"/>
        <map:transform src="simple.xslt">
          <map:parameter name='background' value='{1}'/>
        </map:transform>
        <map:serialize type="html"/>
      </map:match>

It's pretty ugly, though, I think.  Isn't there a (relatively) easy way to
set, say, a request parameter that would be visible in the sub-sitemap?

I don't think it's that ugly – maybe the pipeline concept just takes a bit getting used to when you're new to Cocoon. IMO passing parameters in URLs is a good practise since this way you create a "pipeline API" that helps others to understand the code.

Another approach would be to attach the color value to the current request as a request attribute. AFAIK there is an action and an input module for this purpose.

-- Andreas


--
Andreas Hartmann, CTO
BeCompany GmbH
http://www.becompany.ch
Tel.: +41 (0) 43 818 57 01


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to