You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@forrest.apache.org by Nigel Hardy <nw...@aber.ac.uk> on 2006/03/02 22:57:30 UTC

Access to the query part of the URL

(Sorry if this is a Cocoon Q. really, but I am working in Forrest and 
similar issues arise here from time to time)

I can happily skin the output of php scripts using redirect-to, the 
FileGenerator etc. as suggested in the Cocoon documentation and at 
various times on this list. That works just fine for me. Unfortunately, 
some of the php scripts I want to use like this take query parts in the 
URL to set parameters. I can't see how to get hold of those in a matcher 
or selector. I can catch "this/that/theother.php" and skin it, but how 
do I get hold of the parameter from "this/that/theother.php?var=42" to 
feed that to the FileGenerator?

Help appreciated.

Nigel

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lt%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nigel Hardy     Tel: +44 1970 622 434.   http://users.aber.ac.uk/nwh/
Dept. Computer Sci,  University of Wales, Aberystwyth, SY23 3DB, UK
Adran Cyfrifiadureg, Prifysgol Cymru,     Aberystwyth, SY23 3DB, UK


Re: Access to the query part of the URL

Posted by Tim Williams <wi...@gmail.com>.
On 3/2/06, Nigel Hardy <nw...@aber.ac.uk> wrote:
> (Sorry if this is a Cocoon Q. really, but I am working in Forrest and
> similar issues arise here from time to time)
>
> I can happily skin the output of php scripts using redirect-to, the
> FileGenerator etc. as suggested in the Cocoon documentation and at
> various times on this list. That works just fine for me. Unfortunately,
> some of the php scripts I want to use like this take query parts in the
> URL to set parameters. I can't see how to get hold of those in a matcher
> or selector. I can catch "this/that/theother.php" and skin it, but how
> do I get hold of the parameter from "this/that/theother.php?var=42" to
> feed that to the FileGenerator?
>
> Help appreciated.
>
> Nigel

Hi Nigel,
I was thinking there was a better page than this but if you scroll
down this page and look for RequestParameterModule it should do what
you need.

http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html

In forrest, I think it's prefix is just like that example so it would
be something like: {request-param:var} to get "42" in your url above.

--tim

Re: Access to the query part of the URL

Posted by Ross Gardler <rg...@apache.org>.
Nigel Hardy wrote:
> (Sorry if this is a Cocoon Q. really, but I am working in Forrest and 
> similar issues arise here from time to time)
> 
> I can happily skin the output of php scripts using redirect-to, the 
> FileGenerator etc. as suggested in the Cocoon documentation and at 
> various times on this list. That works just fine for me. Unfortunately, 
> some of the php scripts I want to use like this take query parts in the 
> URL to set parameters. I can't see how to get hold of those in a matcher 
> or selector. I can catch "this/that/theother.php" and skin it, but how 
> do I get hold of the parameter from "this/that/theother.php?var=42" to 
> feed that to the FileGenerator?
> 
> Help appreciated.

If you are planning on using Forrest to generate static content from 
these PHP scripts I'm afraid you can't. The problem is that '?' is not a 
valid character in filenames. Cocoon therefore rewrites such URLs with 
an '_', which then breaks any static links to that page.

If you intend to use Forrest in dynamic mode then you have no problem.

How? Well, as you say this is a Cocoon question, so best place to look 
is the Cocoon docs. See below for some starting options. Which is right 
for you depends on your use case, but given your question I think the 
RequestModule is what you need. Basically, just do {request:PARAM-NAME}:

One of the RequestModules [1]

The request selector [2]

The request generator [3]

Ross

[1] http://cocoon.apache.org/2.1/userdocs/concepts/modules-ref.html

[2] http://cocoon.apache.org/2.1/userdocs/requestparameter-selector.html

[3] http://cocoon.apache.org/2.1/userdocs/request-generator.html

Re: Access to the query part of the URL

Posted by Thorsten Scherler <th...@apache.org>.
El vie, 03-03-2006 a las 17:15 +0000, Ross Gardler escribió:
> Tim Williams wrote:
> > On 3/3/06, Nigel Hardy <nw...@aber.ac.uk> wrote:
> > 
> >>Nigel Hardy wrote:
> >>
> >>
> >>>I can happily skin the output of php scripts using redirect-to, the
> >>>FileGenerator etc. as suggested in the Cocoon documentation and at
> >>>various times on this list. That works just fine for me.
> >>>Unfortunately, some of the php scripts I want to use like this take
> >>>query parts in the URL to set parameters. I can't see how to get hold
> >>>of those in a matcher or selector. I can catch
> >>>"this/that/theother.php" and skin it, but how do I get hold of the
> >>>parameter from "this/that/theother.php?var=42" to feed that to the
> >>>FileGenerator?
> >>
> >>Thank you for the quick and informative replies. I think they can be
> >>summed up as simple redirection is not possible because the query parts
> >>get disassembled. I would need to re-build a new URL if the original has
> >>an unknown list of parameters. The mechanisms work on known parameters.
> >>
> >>Thanks.
> >>
> >>Nigel
> > 
> > 
> > I think that's a hasty summation;)  Take a look:
> > http://wiki.apache.org/cocoon/InputModules
> > 
> > Look for "RequestModule (JXPath)", specifically, the queryString
> > property.  It'll let you pass it along in full: {request:queryString}
> 
> Tim and I seem to be overlapping with our replies on this thread :-), I 
> see he has seen a second potential use case that you may be describing.
> 
> Without understanding the use case it's hard to know exactly what to 
> suggest, If you can't follow what we are suggesting it really would help 
> to give a concrete example of what you want to do then we can give 
> unambiguous answers. Clearly your generic request to "get hold of the
> parameter from "this/that/theother.php?var=42" to feed that to the
> FileGenerator?" is not a detailed enough use case as we have provided a 
> number of ways of doing this.

Well the *easiest* way if you use xsl then set in your sitemap
<map:parameter name="use-request-parameters" value="true"/>
then you can get any <xsl:param/> that you want. 

El vie, 03-03-2006 a las 17:15 +0000, Ross Gardler escribió:
> Without understanding the use case it's hard to know exactly what to 
> suggest

;)

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Access to the query part of the URL

Posted by Ross Gardler <rg...@apache.org>.
Tim Williams wrote:
> On 3/3/06, Nigel Hardy <nw...@aber.ac.uk> wrote:
> 
>>Nigel Hardy wrote:
>>
>>
>>>I can happily skin the output of php scripts using redirect-to, the
>>>FileGenerator etc. as suggested in the Cocoon documentation and at
>>>various times on this list. That works just fine for me.
>>>Unfortunately, some of the php scripts I want to use like this take
>>>query parts in the URL to set parameters. I can't see how to get hold
>>>of those in a matcher or selector. I can catch
>>>"this/that/theother.php" and skin it, but how do I get hold of the
>>>parameter from "this/that/theother.php?var=42" to feed that to the
>>>FileGenerator?
>>
>>Thank you for the quick and informative replies. I think they can be
>>summed up as simple redirection is not possible because the query parts
>>get disassembled. I would need to re-build a new URL if the original has
>>an unknown list of parameters. The mechanisms work on known parameters.
>>
>>Thanks.
>>
>>Nigel
> 
> 
> I think that's a hasty summation;)  Take a look:
> http://wiki.apache.org/cocoon/InputModules
> 
> Look for "RequestModule (JXPath)", specifically, the queryString
> property.  It'll let you pass it along in full: {request:queryString}

Tim and I seem to be overlapping with our replies on this thread :-), I 
see he has seen a second potential use case that you may be describing.

Without understanding the use case it's hard to know exactly what to 
suggest, If you can't follow what we are suggesting it really would help 
to give a concrete example of what you want to do then we can give 
unambiguous answers. Clearly your generic request to "get hold of the
parameter from "this/that/theother.php?var=42" to feed that to the
FileGenerator?" is not a detailed enough use case as we have provided a 
number of ways of doing this.

Ross

Ross

Re: Access to the query part of the URL

Posted by Ross Gardler <rg...@apache.org>.
Nigel Hardy wrote:
> Tim Williams wrote:

...

>> Look for "RequestModule (JXPath)", specifically, the queryString
>> property.  It'll let you pass it along in full: {request:queryString}
>>  
>>
> That is what I was looking for!
> 
> Sorry if my question was not sufficiently clear. 

It was clear enough for Tim ;-)

> With Tim's call I now 
> have a general plugin which will let me skin the output of php scripts 
> but, should those scripts themselves produce links to scripts with query 
> strings, then the subsequent "parameterised call" is also skinned. 


Great!

Any chance of packaging this as a plugin and contributing it to the 
project? We already have a PHP plugin in whiteboard, it would be great 
to compare your solution with that plugin and cherry pick the best from 
both.

Even better if you could bring the two together before you contribute 
your code. Don't worry if you don't have the time to polish it, there 
are others using Forrest + PHP, they may have the time to help out. If 
not, ou don't lose anything.

If you are able to do this please attach it to an issue in Jira.

Ross

Re: Access to the query part of the URL

Posted by Nigel Hardy <nw...@aber.ac.uk>.
Tim Williams wrote:

>On 3/3/06, Nigel Hardy <nw...@aber.ac.uk> wrote:
>  
>
>>Nigel Hardy wrote:
>>
>>    
>>
>>>I can happily skin the output of php scripts using redirect-to, the
>>>FileGenerator etc. as suggested in the Cocoon documentation and at
>>>various times on this list. That works just fine for me.
>>>Unfortunately, some of the php scripts I want to use like this take
>>>query parts in the URL to set parameters. I can't see how to get hold
>>>of those in a matcher or selector. I can catch
>>>"this/that/theother.php" and skin it, but how do I get hold of the
>>>parameter from "this/that/theother.php?var=42" to feed that to the
>>>FileGenerator?
>>>      
>>>
>>Thank you for the quick and informative replies. I think they can be
>>summed up as simple redirection is not possible because the query parts
>>get disassembled. I would need to re-build a new URL if the original has
>>an unknown list of parameters. The mechanisms work on known parameters.
>>
>>Thanks.
>>
>>Nigel
>>    
>>
>
>I think that's a hasty summation;)  Take a look:
>http://wiki.apache.org/cocoon/InputModules
>
>Look for "RequestModule (JXPath)", specifically, the queryString
>property.  It'll let you pass it along in full: {request:queryString}
>  
>
That is what I was looking for!

Sorry if my question was not sufficiently clear. With Tim's call I now 
have a general plugin which will let me skin the output of php scripts 
but, should those scripts themselves produce links to scripts with query 
strings, then the subsequent "parameterised call" is also skinned. My 
application is a set of prototype database interface scripts which is 
becoming unwieldy to manage as a set. Forrest will allow me to quickly 
provide a navigation front end which, conveniently, can be part of a 
pre-existing project site generated by Forrest.

Nigel

p.s. Well, I will have such a plugin when I have done the fleshing out.

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lt%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nigel Hardy     Tel: +44 1970 622 434.   http://users.aber.ac.uk/nwh/
Dept. Computer Sci,  University of Wales, Aberystwyth, SY23 3DB, UK
Adran Cyfrifiadureg, Prifysgol Cymru,     Aberystwyth, SY23 3DB, UK


Re: Access to the query part of the URL

Posted by Tim Williams <wi...@gmail.com>.
On 3/3/06, Nigel Hardy <nw...@aber.ac.uk> wrote:
> Nigel Hardy wrote:
>
> > I can happily skin the output of php scripts using redirect-to, the
> > FileGenerator etc. as suggested in the Cocoon documentation and at
> > various times on this list. That works just fine for me.
> > Unfortunately, some of the php scripts I want to use like this take
> > query parts in the URL to set parameters. I can't see how to get hold
> > of those in a matcher or selector. I can catch
> > "this/that/theother.php" and skin it, but how do I get hold of the
> > parameter from "this/that/theother.php?var=42" to feed that to the
> > FileGenerator?
>
> Thank you for the quick and informative replies. I think they can be
> summed up as simple redirection is not possible because the query parts
> get disassembled. I would need to re-build a new URL if the original has
> an unknown list of parameters. The mechanisms work on known parameters.
>
> Thanks.
>
> Nigel

I think that's a hasty summation;)  Take a look:
http://wiki.apache.org/cocoon/InputModules

Look for "RequestModule (JXPath)", specifically, the queryString
property.  It'll let you pass it along in full: {request:queryString}

--tim

Re: Access to the query part of the URL

Posted by Ross Gardler <rg...@apache.org>.
Nigel Hardy wrote:
> Nigel Hardy wrote:
> 
>> I can happily skin the output of php scripts using redirect-to, the 
>> FileGenerator etc. as suggested in the Cocoon documentation and at 
>> various times on this list. That works just fine for me. 
>> Unfortunately, some of the php scripts I want to use like this take 
>> query parts in the URL to set parameters. I can't see how to get hold 
>> of those in a matcher or selector. I can catch 
>> "this/that/theother.php" and skin it, but how do I get hold of the 
>> parameter from "this/that/theother.php?var=42" to feed that to the 
>> FileGenerator?
> 
> 
> Thank you for the quick and informative replies. I think they can be 
> summed up as simple redirection is not possible because the query parts 
> get disassembled. I would need to re-build a new URL if the original has 
> an unknown list of parameters. The mechanisms work on known parameters.

I still don't understand your use case since you have not described it. 
It is therefore difficult to give accurate information. However, if you 
have an unknown list of parameters then you probably want the 
RequestGenerator. This will create an XML document from any query data. 
You can then use that in a pipeline and processes it like any other 
document.

I linked to the RequestGenereator in my original reply.

What confuses me is how you intend to make use of an unknown set of 
parameters.

Ross

Re: Access to the query part of the URL

Posted by Nigel Hardy <nw...@aber.ac.uk>.
Nigel Hardy wrote:

> I can happily skin the output of php scripts using redirect-to, the 
> FileGenerator etc. as suggested in the Cocoon documentation and at 
> various times on this list. That works just fine for me. 
> Unfortunately, some of the php scripts I want to use like this take 
> query parts in the URL to set parameters. I can't see how to get hold 
> of those in a matcher or selector. I can catch 
> "this/that/theother.php" and skin it, but how do I get hold of the 
> parameter from "this/that/theother.php?var=42" to feed that to the 
> FileGenerator?

Thank you for the quick and informative replies. I think they can be 
summed up as simple redirection is not possible because the query parts 
get disassembled. I would need to re-build a new URL if the original has 
an unknown list of parameters. The mechanisms work on known parameters.

Thanks.

Nigel

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%lt%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Nigel Hardy     Tel: +44 1970 622 434.   http://users.aber.ac.uk/nwh/
Dept. Computer Sci,  University of Wales, Aberystwyth, SY23 3DB, UK
Adran Cyfrifiadureg, Prifysgol Cymru,     Aberystwyth, SY23 3DB, UK