Querystring in Admin menu

Topics: Customizing Orchard, Writing modules
Jul 4, 2012 at 12:02 PM

Hey Everyone,

I'm looking for a way to instert a querystring for filtering contentitems

I have a list of schools (content items) which are presented like this int the backend:

http://localhost:30320/OrchardLocal/Admin/Contents/List/School

Somewhere in my code I do a redirecttoaction like this:

return RedirectToAction("List", "Admin", new { area = "Contents", id = "School", });

Now I want to add a querystring so I get only the schools who are located in a specific city

(SchoolPartRecord.CityRecord.Id)

Is that possible and how can I construct the querystring to return something like "where School.CityRecord.Id == CityId

CityId will also be a variable that comes from my code.

Thanks,

Borrie

Coordinator
Jul 5, 2012 at 2:21 AM

If I'm not mistaken, if you add properties to that anonymous objects that the system can't relate to known route tokens, it will just add them as querystring parameters.

Jul 5, 2012 at 9:53 AM

Bertrand,

I don't understand, I'm looking for something like http://localhost:30320/OrchardLocal/Admin/Contents/List/School&CityName=CityName

How can I accomplish that?

Borrie

Developer
Jul 5, 2012 at 9:17 PM
Edited Jul 5, 2012 at 9:17 PM

As Bertrand mentioned, you can just add another property to the anonymous object that you are passing as the 3rd argument, like this:

return RedirectToAction("List", "Admin", new { area = "Contents", id = "School", CityName = "Sidney" });

However, I don't think the Contents controller will know what to do with that extra parameter, so nothing special will happen. If you want to handle this extra filter, you can create your own admin controller in your own module. Although I'm not quite sure, I believe that 1.5 will enable you to create customized query views straight from the admin. Then again, I may be mistaken.

Jul 6, 2012 at 8:51 AM

Skywalker,

Thanks, I've already tried that and like you said nothing happens because the controller doesn't know what to do with it, Do you think I can add some code to my schooldriver for that? I would like to use the system already present for the backend, it seems a bit much to rewrite the whole thing, I would also like to add custom filtering in the backend (like a dropbox to filter on the cities) Do you think that's possible or should I wait till 1.5? (do you know when that will be released?)

Borrie

Coordinator
Jul 11, 2012 at 2:15 PM

Why don't you implement your own controller?

Jul 11, 2012 at 4:48 PM

Bertrand,

Can I create my own controller and still link in to the dashboard system of Orchard?

It seems a bit much to rewrite the whole thing just to filter on something.

Borrie

Coordinator
Jul 11, 2012 at 5:09 PM

Of course. There is nothing magical about existing controllers and admin menu items.