Maintaining a blog powered by Orchard using WebMatrix
Orchard is one of the most powerful content management system developed on top the Microsoft stack and is widely used across the globe with the recent being the blogs hosted under weblogs.asp.net is now being powered by Orchard. You can read more about it in John Galloway’s blog here.
I have also migrated mine from DotNetNuke to Orchard at turn of the year and it’s been good journey so far when compared to DNN, eventhough faced some hiccups here and there. When compared to other CMS like WordPress or Blogger, Orchard is lacking some of the features and needs to do some workarounds for acheiving that. Couple of things I liked most in Orchard is the support for Bootstrap theme and the widgets, it’s really easy and fun playing with it.
So coming back to our topic, I am not a good fan of the inbuilt editors in the dashboard of many CMS for authoring the posts, so I normally use Windows Live Writer for writing and publish my posts. If you are a blogger and hearing it for the first time, go ahead to download page at Microsoft site to have try. If you are a developer, then certainly you will like to play around with the inner working of various components in Orchard. Even though there are variety of options like Visual Studio itself, I found WebMatrix as a great tool for doing most of the nitty gritty works. It’s free, small download size, light weight and easy to use. To know more about it, go through this link and also has the link for downloading it too.
The home page will have the options as shown in the image below.
My site is already hosted as a shared site with one of the providers and I will be downloading it from there to do all the work locally and then push it to into the production once I am satisfied with all the changes. For that I will be creating a empty site from the New option.
The next page will have the options for connecting with the service provider. Some of the providers will allow you to publish the site over WebMatrix or Visual Studio by using the profile file from the control panel otherwise we need to manually enter the details such as Server, Username, Password manually to set up the connection. Anyway WebMatrix supports both these methods and if you have a publish profile from the control panel, then you can import it to Publish setting page, if not then key in the details.
If your service provider supports web deploy, please locate the screen similar to the one below in your control panel
In my case the provider supports it and will be using the profile file to pre populate the publish settings by importing it. The page also has the option to validate the connection settings.
Once you successfully set up WebMatrix, you can proceed to download the content from the server, which can be done from the Download option in the Remote Tab. When you click on it, will show a window with the changed files and the database. To proceed with the download push the Continue button.
Now we have downloaded all the files from the server and let’s see how we can make changes in the code and then publish it back to the production server. What I am going to do is that is to remove the attribution content in the footer of the home page.
As I explained in one of the earlier post, I will be using shape tracing to determine the content part responsible for this and will make changes accordingly.
So from the image we can figure out that the BadgeofHonor.cshtml file is the one which is rendering all those attribution details and its in the Footer Zone. All the views in Orchard is making use of the Layout.cshtml page as the container and let’s check the content of the file to make sure that this particular view is being called there.
WorkContext.Layout.Header.Add(New.Branding(), "0"); // Site name and link to the home page WorkContext.Layout.Footer.Add(New.BadgeOfHonor(), "5"); // Powered by Raptor Concepts WorkContext.Layout.Navigation.Add(New.User(), "5"); // Login and dashboard links
We are now going to comment out the second line to achieve our objective and we test it out locally in the browser by clicking on the Run menu item in the Home Tab.
Now to publish it on to the production server , you can click on the Publish menu item in the Remote Tab which will bring up the Publish settings window where it displays all the changed files which are pending for upload. I will be selecting the modified cshtml file only and will uncheck the rest of the files.
That’s all we need to do for transferring the file to the server from your local testing environment. So till next time Happy Coding !!!
Breaking Changes coming your way for ASP.NET Core 3.0
Resilient Connections in Entity Framework Core