Updating the Correlate Task, fixing CSS intermittent encoding issue and a demo about statically typed URL creation! Do you want to know more? Then check out our last post of this year!
Orchard Core updates
Fix Correlate Task
Fix CSS intermittent encoding issue
The cache on the browser was serving the CSS files using differently than UTF-8. When you disabled the cache on the browser it was fine. So, the cache is storing it as ASCII and not UTF-8. If you check out the picture below, you can see some weird characters on the screen.
So, the problem here was a charset issue because browsers can handle different charsets if you put the information at the top of the file. But some of the stylesheets of Orchard Core were started with some comments and not with the line which is saying the given charset. And it looks like browsers only include the charset if it's in the first line of the stylesheet. So, the headers for the stylesheets are not injected anymore.
Statically typed URL creation
The Lombiq Helpful Libraries for Orchard Core contains various libraries that can be handy when developing for Orchard Core CMS, to be used from your own Orchard modules.
The Helpful Libraries now has a new class called TypedRoute which provides a strongly typed way to generate local URLs for Orchard Core MVC actions. It uses lambda expressions to select the action and provide arguments. Use
TypedRoute.CreateFromExpression<TClass>(...).ToString() or the provided
HttpContext.Action() extensions. Let's see this in action!
In this demo, we will go with the quicker way and use our Open-Source Orchard Core Extensions full Orchard Core solution that contains that module with a nice sample. If you clone that repository and set up your site using any setup recipe, let's just navigate to the admin UI of Orchard Core, and under Configuration -> Features, enable the Lombiq Helpful Libraries for Orchard Core - Samples feature.
Now, head to the /Lombiq.HelpfulLibraries.Samples/TypedRoute/Index URL to see the content of the following Razor file.
As you can see, we constructed the first URL by using the anchor tag helper from ASP.NET Core. Here we needed to pass the area, the name of the controller, and the action and put the names of the accepted properties by the controller action by using the asp-route- prefix. If you use the extension, you can statically enter the controller name (TypedRouteController in this case) and using lambda you can select the TypedRouteSample action by passing the values you want.
In this way, you can safely rename the controller or the action without breaking any functionality in your Razor file, because Visual Studio and Rider will also be able to find the references in your Razor files too.
Do you want to know more and look under the hood of this feature? Well, you just need to check out this short presentation on YouTube!
News from the community
Christmas in Lombiq
Sometimes we do stuff. Together. Not (just) in front of computer screens. These are some usual events in Lombiq that are all announced and arranged in advance. We periodically have an event called RnDay: this is a few hours long event where we share with each other what we recently worked on and what we plan to do. E.g. if we recently finished a project then the project's team members demo what they've done. This week we had our last RnDay for this year but this time (again), we have to make it online. We also named this event The 14th RnDay - Pandemic Edition 2! We also tried to do our best to make a nice group photo, you can see the result down below. :)
We would like to thank you all for reading our posts and making the Orchard community stronger together with us! We hope that we could give you valuable news and demos about the happenings around Orchard and Orchard Core from time to time by reading our posts and of course the This week in Orchard newsletter. We would like to wish everyone a Merry Christmas and a Happy New Year! See you next year!
Orchard Dojo Newsletter
Lombiq's Orchard Dojo Newsletter has 234 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here!