Route.cs: "ChangeCulture"

Topics: Troubleshooting
Apr 1, 2011 at 3:44 PM
Edited Apr 1, 2011 at 4:01 PM

There is a todo line saying:

//TODO (ermakovich): still not sure why we need it, but without this route Orchard can`t find controller action properly

I removed the route and it still works (using 2nd iteration 1.0->1.1). Maybe there were some fixes since 1.0 but I would suggest removing the whitespace from the module name (first line in module.txt: "Culture Picker" -> "CulturePicker").

With the existing whitespace the Html.BeginForm of CulturePicker.cshtml gets rendered like this:

<form action="/Orchard.CulturePicker/UserCulture/ChangeCulture" method="post">

(maybe it didn't render or rendered bullshit using 1.0) and without the whitespace:

<form action="/CulturePicker/UserCulture/ChangeCulture" method="post">

 

The comments module works the same way without a special route.

Coordinator
Apr 5, 2011 at 2:43 PM

There were a lot of problems with routing in the first version of Culture Picker.

In module version 1.1.2 I`ve added "Area" parameter to the BeginForm method. Now it looks like:

Html.BeginForm("ChangeCulture", "UserCulture", new { Area = "Orchard.CulturePicker" })

And it gets rendered like:

<form action="/ChangeCulture" method="post">

So, "ChangeCulture" route does the trick.

 

Regarding module name. Good point. If I understand correctly, Orchard uses module name as a source with the lowest priority, when it`s trying to find a controller. Since the route was introduced, module name actually should not affect anything.

Apr 5, 2011 at 2:52 PM
Edited Apr 5, 2011 at 2:55 PM

According to the newest docs for 1.1 the whitespace inside the name will be fine and you could specify a short "slug" for your controllers and actions using the "Path" parameter: http://orchardproject.net/docs/manifest-files.ashx

And for the Area parameter: If you use it (and you should) you can just remove the route and everything will work: The BeginForm will just render the real path to your controller -- influenzed by Module.txt->Path or Route.cs.

(But you may have to restart the application pool if you change Module.txt->Path or Module.txt->Name)

Coordinator
Apr 5, 2011 at 3:05 PM
Edited Apr 5, 2011 at 3:05 PM

Thanks for the link. I didn`t test Culture Picker with 1.1 branch yet, but I`m planning to download it and test today. Maybe as a result new branch will be created for the Culture Picker.

Coordinator
Apr 5, 2011 at 3:14 PM
Edited Apr 5, 2011 at 3:14 PM
mspring wrote:

And for the Area parameter: If you use it (and you should) you can just remove the route and everything will work: The BeginForm will just render the real path to your controller -- influenzed by Module.txt->Path or Route.cs.

(But you may have to restart the application pool if you change Module.txt->Path or Module.txt->Name)

Ok, will check.

Apr 5, 2011 at 3:16 PM

When you switch to 1.1 please have a look at Piotrs Advanced Menu (formerly Hierarchical Menu): He now is disabling the original NavigationProdivder in a different way using OrchardSuppressDependencyAttribute (which is new to 1.1): http://www.szmyd.com.pl/blog/featuring-orchard-advanced-menu#comments

Coordinator
Apr 5, 2011 at 3:44 PM
Edited Apr 5, 2011 at 3:44 PM

Wow! Thanks! It`s cool that they have introduced such attribute. It can probably help me to provide Lists filtering feature.