cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Klortho <Voldr...@gmail.com>
Subject Re: Passing "parameters" to mounted sub-sitemaps
Date Fri, 27 Feb 2009 02:47:37 GMT

Well, I've been liking it more as I've been thinking about it off and on
today.
I simplified it somewhat:
       <map:match pattern='Z/**'>
         <map:select type='resource-exists'>
           <map:when test='A/sitemap.xmap'>
             <map:redirect-to uri='cocoon:/A/{1}'/>
           </map:when>
           <map:when test='B/sitemap.xmap'>
             <map:redirect-to uri='cocoon:/B/{1}'/>
           </map:when>
         </map:select>
       </map:match>

       <map:match pattern='A/**'>
         <map:mount uri-prefix='' src='A/sitemap.xmap'/>
       </map:match>
       <map:match pattern='B/**'>
         <map:mount uri-prefix='' src='B/sitemap.xmap'/>
       </map:match>

This way "/Z/..." URLs just act like virtual "/A/..." or "/B/..." URLs. 
Changing the uri-prefix to the empty string means that the A and B sitemaps
know who they are.  That makes more sense than a "color" parameter, because
there are other things I might want to do with that info.

Again, thanks for the help!


Andreas Hartmann wrote:
> 
> 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: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Passing-%22parameters%22-to-mounted-sub-sitemaps-tp22218255p22238598.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message