Projections URL String variables

Topics: Core
Apr 13, 2012 at 10:22 PM

Is there a way to create a projections page like (~/list) and be able to pass a query string to provide query content results like in the queries module?

For example: http://www.example..com/list?state=california

Then I can create a single projection page for multiple lists.

Coordinator
Apr 14, 2012 at 12:37 AM

Yes, you can use tokens in projection filters, and there are tokens for querystring parameters.

Jul 5, 2012 at 10:18 AM

Dayton,

How did you solve this issue? I'm also trying to add a query string to filter contenttypes in the backend of Orchard.

Borrie

Jul 5, 2012 at 4:12 PM
Edited Jul 5, 2012 at 4:13 PM

I was able to resolve my problem. On the query I added the following filter:

User Agency Information Part.Address State Code contains '{Request.QueryString:AddressStateCode}'

Which is really just "Request.QueryString:<any field>"

And the in my rewwrite rules I have this:

RewriteRule ^/something-agencies/(.*) /something-agencies?addressstatecode=$1 [NC,L]

So if someone opens or I have a link on my site to the URL /something-agencies/california it will query the content by /something-agencies?addressstatecode=california which will hit my projections page and use this query.

Hope this is helpful.

Jul 6, 2012 at 9:59 AM

Clayton,

Thanks for your answer, do you mean you bring this filter on the frontend? I'm looking for a way to custom filter items on the backend or do you think I  can use this method also for that?

Borrie

Jul 6, 2012 at 9:34 PM

Hi Borrie,

My goal was to be able to use a single projection page to display multiple datasets from a content type. I was able to do that by creating a query with a string variable like I mentioned in my previous post. In this specific case, I had a large set of data that I wanted to display on a page by state. I also wanted a friendly URL and I wanted to include a title tag on the page that was specific to the information I was displaying.

So I have a link on my site that goes to /something-agencies/california, the data that is returned would be all agencies in california using this string /something-agencies?addressstatecode=california and the title tag on the page will be "California Something Agencies" all using a single projection page.

Anyway - I don't know if that helps you, but that was my goal and how I accomplished it.

Clayton

Jul 7, 2012 at 1:03 AM

Clayton,

Thanks a lot for taking the time to answer, your example will help me a lot also for what I want to accomplish! If I find the code to do that functionality in the backend I will post it here.

Cheers,

Borrie