Our blog contains the activity stream of Orchard Dojo: general news, new resources or tutorials are announced here.

Add Recipe Roles permission behavior, how to add media management to an ASP.NET Core app? - This week in Orchard (24/01/2025)

This week's topics are migrating the OpenID module to OpenIddict 6, adding Recipe Roles permission behavior, and we will mention our latest Orchard Nuggets post, where you can learn how to add media management to an ASP.NET Core app. Without further ado, let's dive in!

Featured tags

IIS
API
SMS
SEO
All tags >

How to add media management to an ASP.NET Core app? - Orchard Core Nuggets

Using media files, such as images, videos, and documents (like PDF files), is a common requirement for a modern website. Media can enhance user experience by making content more engaging, visually appealing, and/or easier to understand. Fortunately, Orchard Core has a built-in solution: the Orchard Core Media feature. As the description says in the official documentation:The Media module provides a UI to upload and organize binary files that can be used while creating content.Are you new to Orchard Core? It's a great open-source framework, and CMS built on ASP.NET Core. Check out the official getting started docs.Let's see Orchard Dojo and its blog for a real-life example of why you would use the media feature. At Orchard Dojo, we mainly use images for two things:Image of trainers: As you can see on the About page.Images for blog posts: For example, in this blog post.We have flexibility, and we can organize the media files using the media feature.Flexibility: Let's say a trainer got a new haircut and wants to update their image. Then, we can overwrite the old image with the same name in the media library, and that's it.Organization: We can have a “Trainers” media folder with the trainers' images, a “Blog Posts” folder with the images for blog posts broken down to years, and a folder for each individual blog post's images.Now, to turn on the feature, go to Configuration → Features and make sure the Media feature is enabled. You can additionally enable these media features: Media Cache: The feature caches remote media files locally, improving performance and reducing bandwidth usage for sites using external storage like Azure Blob or S3. For example, an online store with product images hosted on cloud storage can deliver images faster to users.Media Slugify: The feature ensures SEO-friendly URLs by automatically renaming new media folders and files to use slugs (e.g., “The team (2020).jpg” becomes “the-team-2020.jpg”). This is useful for improving search visibility, such as when uploading product images for an e-commerce site. The URLs are also just nicer.Secure Media: This feature allows administrators to control access to media folders based on user roles, ensuring only authorized users can view or manage specific files. For example, a company could restrict marketing files to the marketing team while allowing all staff to access shared resources, enhancing security and organization. If you are new to Orchard Core, you can check out user management (including adding permissions to roles) in one of our Dojo Course videos (to learn more about Dojo Course, click here).After enabling the Media feature, go to the Content menu, and you will see the Media Library menu item. Inside the Media Library, you will see one already existing folder named “_Users”. You can read about this here in detail. But in a nutshell, Orchard Core's Media Library includes a “_Users” folder with subfolders for each user, allowing them to manage their own media. New permissions like Manage All Media Folders and Manage Own Media let admins control access while restricting editors to their folders.A few buttons are not self-explanatory in the media library; we will go through them. With the plus button, you can add new folders to the media library. Just click on the folder and type its name. If you click on an existing folder, follow the same process; the new folder will be created as a subfolder of the current one.The invert button inverts the selection, so if you have image-1.jpg, image-2.jpg, and image-3.jpg, and you selected images 1 and 2, if you click on it, images 1 and 2 will be unselected, and 3 will be selected.With these buttons, you can change between list and grid view: This is the button for uploading files. You can select them from your computer, but you can also just drag them into the empty space in your folder in the media library.The delete button is also available, which is mainly for mass deleting files. If you want to do something with only one file, you can click on it, and three options will appear: rename, delete, and download. You can also filter by file name, that option is left to the upload button (4).Turning on different media features will also add new menu items to the Media menu under the Configuration menu. Media Cache: This menu item appears only if you turn on the Media Cache feature, which we discussed earlier. It contains options related to that feature, such as purging all the assets from the cache.Media Options: Here, you can see the configured media options. One option, for example, is Allowed file extensions, which tell you files with which extensions may be uploaded. You can configure these options from the appsettings.json file or other ASP.NET Core configuration providers. You can read more about it here. For example, if you want to allow only image uploads, you can specify extensions like .jpg, .png, or .gif. This ensures users can upload only images, preventing unauthorized file types like .exe or .zip.Media Profiles: In this menu item, you can define custom image transformations, such as resizing or cropping, to ensure consistent formatting across your site. For example, you can create a thumbnail profile that automatically resizes all product images to 200x200 pixels for a uniform storefront display.When you turn on the Media feature, you will also have a new content field, the media field. Returning to our example, we have trainers on the About page on Orchard Dojo. We already have a widget dedicated to trainers. A media field called image was added to the content type. You can see the media field's settings here: For example, when using the “Multiple” option, we can display multiple images in one media field. With the media field added, when we are creating a Trainer Widget, we can select an image: The plus button opens the media library, where you can select your image. After selecting the image, you will get a small preview of it: But let's see the blog post example. In our Blog Post content type, we have an HTML body (with the Trumbowyg editor). This supports adding an image with the image shortcode. Clicking on the “Insert Media” button, you can select the file from the media library. The result will be something like this: [], and the image will appear in the blog post after publishing it.In this blog post, we’ve seen Orchard Dojo's media library and how we use it, but let's look at another example: You have an e-commerce page where you sell tech products. With the Media feature, you can create product content items with media fields to display images of the products (even multiple with one media field). Let's say on the same site, you are also reviewing tech products in a blog-like format. When you are writing a review, you can use the image shortcode in the HTML body to display your photos of the product.To conclude, Orchard Core’s Media feature makes it easy and effective to manage media files across your site. With features like customizable media profiles, caching, and role-based access, it helps keep your media organized.Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to add import/export to an ASP.NET Core app? - Orchard Core Nuggets

When working with an ASP.NET Core application, it’s often necessary to move various content or configurations between different environments or back up critical information. Whether you’re setting up a new site, migrating content, or synchronizing data across multiple instances, the Orchard Core Deployment feature can simplify the process. This feature provides an easy solution for importing and exporting data.Are you new to Orchard Core? It's a great open-source framework and CMS built on ASP.NET Core. Check out the official getting started docs.Let’s say you manage multiple sites for clients. You might have a standard set of content (like sample blog posts, landing pages, or settings) to help clients get started. With Orchard Core Deployment, you can create these once, export them, and import them into each new Orchard Core instance to streamline the onboarding process. A similar example would be to move content or configuration between a staging and production app.To get started, go to Configuration → Features and search for “Deployment”. Some features will also enable others explicitly. We will go through each feature and explain what they do. Deployment: Offers a framework for importing and exporting recipes, JSON files containing configuration and content. This feature is the foundation of deployment (how we call export-import) in Orchard Core, allowing for the structured export and import of content, technical configuration, and user-editable settings for entire sites or specific components.Remote Deployment: Extends the deployment feature by allowing content export and import to and from a remote server. This feature is useful when managing Orchard Core installations across multiple environments, enabling direct deployment to remote instances, without downloading and uploading JSON files.Add Content To Deployment Plan: This feature adds an action in the content item action list to include specific content items in a deployment plan. This is useful when you want to select specific items to deploy without including the entire site’s content.Export Content To Deployment Target: Adds an option to the content item action list that allows you to directly export content items to a specified deployment target (including downloading the recipe, thus basically the content item inside a JSON file locally).View Or Download Content As JSON: Provides an action in the content item action list to view or download content as JSON files. This feature is helpful for reviewing content item details or troubleshooting.Here is an example of all the content item list actions that are added by these features:These actions focus on single content items and they are really simple. “View as JSON” and “Download as JSON” options are self-explanatory. If you select “Add to Deployment Plan” you will get a list of your current deployment plans and a default one will be created (“Export content to deployment plan target”):“Export to Deployment Target” will list the deployment targets. The default one is “File Download”:But what is a deployment plan? It’s a collection of steps that together produce a recipe JSON file. You can have multiple deployment plans. Let’s create one! Go to Configuration → Import/Export → Deployment Plans. Here you can see your deployment plans, rename them (with “Edit”), delete them, and modify them (“Manage Steps”).image alt="Deployment plans inside menu"]BlogPost/orchard-nuggets/2024/how-to-add-import-export-to-an-asp-net-core-app/deployment-plans-inside-menu.png[/image]Click on the “Add Deployment Plan” button. Here you can name your new deployment plan.After that, you can create the plan, and then you will see it in the list. Now click on the “Manage Steps” button for your deployment plan. You will see this screen, but it’s empty since you need to click on the “Add Step” button to add steps:Here you will see all the available steps:They have descriptions, but just to name a few important ones:All Content: Exports all the content items of the system.Content: Exports all content items for specified content types.Content Item: Exports a specified content item.All Features: Exports the state of all features, ensuring the same features are enabled or disabled across sites.We have two Page content items in our case, so let’s export those with the “My second deployment plan”.Add the “Content” step. Then select the Page content type. Additionally, you can check the “Export As Setup Recipe” option if the data should be exported as a Setup recipe. A setup recipe in Orchard Core is a JSON file that contains instructions for setting up content, configuration, and features on a new or existing Orchard Core instance, structured to automate the setup of a site. It’s almost the same as a recipe that you can export with the Deployment feature, just it needs to contain everything to set up a site, not just e.g. a couple of pages.After that, you can add the step by clicking on “Create” and execute the plan with “Execute”:When executing you can again select the target. The default option here is the previously mentioned “File Download” to download the deployment plan locally. This will download a ZIP file that has the “Recipe.json” file inside. This will contain in our case all the page content items.Okay, but how do you import? Go to Configuration → Import/Export. You will have multiple options:JSON Import: Here you can directly insert your Recipe.json file. You can copy the file's content, or you can also just drag the file there. The content will be visible as JSON and you can edit it before importing. In this example, we used the recipe which was inside the ZIP that we downloaded from “My second deployment plan”.Package Import: Imports a complete package (ZIP file) containing multiple JSON files, media files (yes you can export media files, by adding the Media step), and other resources. So this is best for large-scale site migrations or complete environment setups. You just need to select the ZIP file, then click on “Import”:In our case, this will throw an error but this is because we already have the two pages (thus the two permalinks of the pages are already in use), but if you import this package in another application that has the Page content type, it will work. But if it doesn’t have the Page content type, you can just add the “Replace Content Definitions” step in your plan, which will also export the content type after you choose it.But what if you want to import to a remote instance? If you have the Orchard Core Deployment Remote enabled you will see two more options under Import/Export: “Remote Clients” and “Remote Instances”.Under “Remote Clients” you can add your remote clients:You will need to set a “Client Name” and an “Api Key”. This will come from the client app. So for example, if you want to import from staging to production, you will need to go to production and create the client.After that, you can enter your staging site, and under “Remote Instances” you can add the instance.You will need to set a name (it’s just for display and can be anything) and a URL (which can be copied from under “Remote Clients” for example in your production app if you are importing to production).Then you will need to set the client name and the API key. These are the ones that you set first in “Remote Clients” in the other app.After that, the instance will be available as a target when exporting something (so it would be imported right into the target).Returning to the example at the beginning:Let’s say you manage multiple sites for clients. You might have a standard set of content (like sample blog posts, landing pages, or settings) to help clients get started.With Orchard Core Deployment, you can create the “template” of these sites, with the necessary items and settings, then export them into a recipe. After that, you can send that to your clients. Or Orchard Core Remote Deployment you can even export the recipe right to your clients' app.Orchard Core’s Deployment features make it easy to move content and configuration across environments or different sites. Whether you're migrating data or synchronizing settings, these tools simplify the process. Want to see these features in action? Check out our tutorial video to learn how to set up and use Orchard Core Deployment features!Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to add an audit trail to an ASP.NET Core app - Orchard Core Nuggets

When you have an ASP.NET Core application, that publishes content often and has different users, it’s a good idea to keep track of what is happening in the app: What changes? What content gets deleted or published by who? Who logged in, and when, did somebody fail to log in repeatedly using a wrong password? Who changed the settings?For example: Imagine you're managing a news portal where multiple articles are being written and published daily. One day, an article titled "Breaking News: Major Policy Change Announced" was accidentally deleted. It was a high-traffic piece, and its sudden disappearance created confusion among readers and the team. As an administrator or perhaps an owner, you want to restore the article, then find out what happened and who made this change. The answer is: Orchard Core and its Audit Trail module.Are you new to Orchard Core? It's a great open-source framework and CMS built on ASP.NET Core. Check out the official getting started docs.The Audit Trail module logs key changes and events in the system, such as content creation, deletion, and login failures. It also allows tracking changes to content, restoring previous versions, and recovering deleted items. It’s all extensible too, so you can add more features with some coding. Let’s see how to use it!First, go to Configuration → Features and make sure the Audit Trail feature is enabled. Optionally, if you also want to track user events (like somebody logging in etc.) you can enable the Users Audit Trail feature too. Please note that enabling the Users Audit Trail feature will automatically enable the base Audit Trail feature, as it is a dependency of the Users Audit Trail. After this, you can access the audit trail settings under Configuration → Settings → Audit Trail. You can see three tabs on the top: Events, Trimming, and Content. Let’s start with Events. Here you can see the events that will trigger an audit trail record, and by default, all of them are enabled. The first set of events is tied to content, so content item creation, removal, etc. You can disable any of those if you want. The second set of events is for the user. This set of events only appears if you enable the Users Audit Trail feature too. These are for user activities, so login, failed login, etc. You can also select to record the client's IP address. We recommend erring on side of caution, and starting with everything enabled, and only disable certain events if it turns out that they’re just noise for your site.Now take a look at the other tab, Trimming. If a site has a lot of activity, perhaps it’s good to delete audit trail logs after a year or so, since the records can eat up a lot of space in the database (it won’t really get slower, but depending on your hosting provider, you may need to pay more). The trimming setting allows you to do that. The default trimming option is 90 days. So any audit trail event that is logged and older than 90 days will be deleted from the database. To avoid trimming you can select the Disable trimming task option. In the Last run field, you can see the most recent time the trimming task was executed.Now, check the content tab. Here you can see the types of content for which events are logged. You can freely disable or enable any of them. In our example, some are enabled, but some are disabled. This is because we configured the audit trail settings in the startup recipe. For example, see this startup recipe in our open-source Lombiq Walkthroughs module. Of course, if you have different content types than our example site, you will see them on this screen. But remember, if a content type is disabled here, its events won’t be recorded (like deletion). Not all content types may be important for you to track. For example, if you're not actively using a particular content type, you might want to disable the logging of it to reduce unnecessary noise. Only track what’s necessary to balance performance and insight. For instance, in the image, just to name one, the tracking of the Layout Injection content type is disabled. This is because it’s a widget that is only used in one place, and it won’t be updated ever likely.Additionally turning on the Audit Trail feature will add a content part called Audit Trail part. This part as the description says: “Allows editors to enter a comment to be saved into the Audit Trail event when saving a content item.” If you add this part to the content type, you will see a new field for a comment, what you can use to add some explanation about the current content change. Staying with the news portal example, each time an editor revises, they can leave a comment in the audit trail explaining what was changed and why. For example, "I reworked the intro paragraph for clarity." This is all good, but how one can see the actual logs? Well, it’s pretty simple, now there is a new tab in the admin menu called Audit Trail. In this example, we had a page content type and audit trail turned on from the beginning. When I set up the site I created an admin user and I logged in. After that, I created a page content item, published it, and deleted it. You can restore deleted content items from the audit trail, so that’s what I did next. Then I renamed the title of the page. You can see all that from the logs: Returning to the example at the beginning:One day, an article titled "Breaking News: Major Policy Change Announced" was accidentally deleted.If the audit trail was turned on for that content type, now there is a solution! Go to the audit trail logs, you will see who deleted it and you can also restore it, correcting all the mistakes.For more audit trail features check out our open-source Orchard Core extension for the Audit Trail module: Lombiq Audit Trail Extensions. Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to add workflows to an ASP.NET Core app - Orchard Core Nuggets

Do you want to send an email, when a form is submitted? Perhaps delete a content item after a certain amount of time? You don't want to write complex codes? Look no further with the Orchard Core Workflows feature you can achieve these, without writing any code. This way people who are not familiar with coding can also easily modify these processes.Are you new to Orchard Core? It's a great open-source framework and CMS built on ASP.NET Core. Check out the official getting started docs.Workflows in Orchard Core can be a powerful tool. A workflow is basically a visual script, that consists of two types of activities: Tasks and Events. A Task activity performs an action, for example sends an email, or creates a notification. An Event activity is like a trigger point, it listens for an event and it can activate Tasks. But why are workflows so useful? Here are some examples of what you can do with workflows:Automatically assigning a role to a user based on their input from a registration form.Moving content to an "Archived" state after a specified number of days since publication.Sending users a weekly email digest summarizing newly published content on the site.Sending a reminder to users who have incomplete profile information after a certain period.This is to name a couple.Let's see how you can create your own workflow! In this example we will create a workflow that displays a notification, but only for users in the Administrator role.First, go to Configuration → Features and make sure the Workflows feature is enabled. Now you can access the workflows in the Workflows menu point. Click on the Create Workflow button. Name the workflows for example "Display Notification for Administrators". You can leave the other settings as they are and click on Save. Now you will see the dashboard of our workflow. Here click on the Add Event button, so our workflow will have a starting point. Select the User LoggedIn activity, you can give it a title but it's not necessary. To make this your startup event, you will need to click on the event and then on the Startup task button. After that, the event card will turn green. Now let's add a task. Click on the Add Task button and select Validate User, as the description says it checks if the user exists for the current request and has the specified role(s)". When adding the task select the Administrator role in roles. Also select Set the 'UserName' workflow property if the user is authenticated. Okay, there is a starting event and a task, but how do we connect them? It's pretty simple: grab the green dot from the top of the starting activity and drag it to the task. We only need one more activity a task that displays notifications. So click on the Add Task button once more and select Notify. For the notification type let's go with Success, the message could be anything, but since we have the username from the previous activity, we can personally welcome the user. You can use Liquid syntax, just like this "Welcome, {{ Workflow.Properties.UserName }}!". After saving it, the only thing left to do is to connect the InRole dot from the top of the Validate User activity to the Sucsess Notification activity. In the end, your workflow should look something like this: Save it, then you can log off and log in with an admin user and see the results: That's it! You can modify this workflow how you want, add more events or tasks and based on this tutorial create your own!Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to change the idle logout time in Orchard Core - Orchard Core Nuggets

Keeping user accounts secure is important. One aspect of this is to constrain how long people can remain logged in: If they share a device, especially a public one, then it's better to be on the safe side and automatically log them out after some time of inactivity. Here is how you can do it in Orchard Core! Since an Orchard Core-using app is in the end just an ASP.NET Core app, you can use the standard Identity options to configure how user sessions work. What governs how long users remain logged in is mostly the cookie settings. This is how you can set it from the Program file of your web app: builder.Services .AddOrchardCms() .ConfigureServices(services => services.ConfigureApplicationCookie(options => options.ExpireTimeSpan = TimeSpan.FromMinutes(30))); This logs users out after 30 minutes of inactivity. You can also set options.SlidingExpiration = false if you'd like this to be counted from the time they logged in, as opposed to the last time they did something in the app. While the above example shows how to do this in the root web app, you can similarly set this from the Startup class of a module or theme. That's it! It's worth checking out the official Orchard Core docs on configuring other Identity options too. Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to do a security scan of an Orchard Core app - Orchard Core Nuggets

You don't want malicious people to crack your web apps to use them for spamming, cryptocurrency mining, and spreading malware, nor do you want them to get access to your users' personal data (if you actually do want to cooperate with criminals, you don't need to read further). Thus, you want your app to be secure. One aspect of achieving this is to do penetration testing on your app. Thankfully, much of this can be automated, and with the help of Lombiq UI Testing Toolbox for Orchard Core and Zed Attack Proxy (ZAP) you can conveniently do this for your Orchard Core app. Let's see how! First, install v8.2.1-alpha.6.osoe-351 or greater of the UI Testing Toolbox from NuGet because that's the one that added security scanning. There are a couple of minor breaking changes that should affect nobody, really, in this, so it'll be part of the upcoming v.9.0.0 (but for that, we're waiting for Orchard Core 1.8). Set up UI testing as explained in the UI Testing Toolbox's documentation. While we're focusing on security scanning here, the UI Testing Toolbox can do a lot, and I really mean a lot more, including one-liners to test if the basic Orchard Core features still work in your app, or unleashing automated monkey testing to try to break your app. We never work on an Orchard Core app without its safety net! Add one or more test cases to run ZAP's security scan. Since all the configuration of ZAP is available to you, customization is unlimited, but to give you a glimpse, this is how a basic security scan that's already a good start would look like: [Fact] public Task BasicSecurityScanShouldPass() => ExecuteTestAfterSetupAsync(context => context.RunAndAssertBaselineSecurityScanAsync()); And that's it! OK, I might have omitted the last step here: 4. Fix all the security issues ZAP finds, because it'll definitely find at least a couple of them! This was just a short teaser, but be sure to check out the UI Testing Toolbox's security scanning documentation, because we tried to summarize everything necessary to get you going there, including samples that you can just copy-paste. Do you want to see security scanning in action? Check out the demo video too! Also, security starts with quality code. Check out our Lombiq .NET Analyzers project to get automated checks for your code too, including pointing out potential security issues even before running the app. Did you like this post? It's part of our Orchard Core Nuggets series where we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out the other posts for more such bite-sized Orchard Core tips and let us know if you have another question!

How to migrate an Orchard 1 application to Orchard Core

How long have you been using Orchard 1 for your website? How satisfied are you with its features and performance? Have you encountered any limitations or challenges with Orchard 1 that you hope to address? If you are looking for a modern and improved version of Orchard 1, you might want to consider migrating to Orchard Core which is a better version of Orchard 1 in many aspects. Orchard Core is not just a port of Orchard 1, but a new and improved system that offers many benefits over its predecessor. What are the benefits of migrating to Orchard Core? You can enjoy numerous remarkable benefits by migrating to Orchard Core. First of all: Performance. As the saying goes: “The faster the better.” Orchard Core is so fast that an output cache module like for Orchard 1 is not required. For example, you can set up a site with the blog recipe in less than half the time that Orchard 1 needs for the same task. It is portable: it can run on Windows, Linux, and macOS, as well as on Docker containers. It has a more flexible and extensible modular framework that allows building modular and multi-tenant applications more easily. Orchard Core also supports NuGet packages for modules and themes, thus creating a new website with it is actually as simple as referencing a single meta package from the NuGet gallery. It is built on ASP.NET Core. This means that it can use any C# language version without any limitations, while Orchard 1 uses .NET Framework 4.8 which means it’s restricted to C# 7.3. It has new features that are not available in Orchard 1, such as GraphQL API, OpenID Connect, Liquid templates support, and more. It supports all major site building strategies: Full CMS, Decupled CMS, Headless CMS. This is just the tip of the iceberg, to read more about Orchard Core check out its documentation. Preparations The first thing to know is that there is no easy or fully automated way to migrate your website and content. The two systems are different in terms of data schema, modules, themes, and features. However, in general, we can say, that proficiency in Orchard 1 puts you in a good position to develop in Orchard Core too. There are a lot of similarities for example menu points on the admin UI, or how migrations work, etc. A good first step would be to take a look at your current application. Do you want to replicate what you have there, or do you also want to improve it? Migration is a good opportunity to renew your site, change design, and functionality, get rid of obsolete elements on the site, etc. You'll also need to know Orchard Core before attempting a migration. If you are new to Orchard Core development, we recommend that you start with our Dojo Course 3 - the full Orchard Core tutorial. This course covers the fundamentals of Orchard Core for both users and developers. New CMS, familiar features Before starting the migration, it is recommended to check your most used, most important features in Orchard 1 and list them. There is a good chance that there is an equivalent feature in Orchard Core, but it changed and has been upgraded, so you will need to do some research. For example, if you want to migrate your custom form, instead of Orchard.DynamicForms you can use OrchardCore.Forms to achieve the same result. Or instead of Orchard.Taxonomies you can use OrchardCore.Taxonomies. The Workflows and Audit Trail modules were ported to Orchard Core and improved too. Migrating content types Content types are composed of content parts and fields, which provide different functionalities and data types for your content. If you want to migrate your content types, you will need to recreate them in the new system. Luckily, as with features most of Orchard 1 content parts and fields have their equivalent in Orchard Core. Some examples are BooleanField, NumericField, TitlePart, or CommonPart. In this case, you can recreate your content type from the admin UI, from a recipe, or with a migration. Let’s say you have a BlogPost content type in Orchard 1, which has the following parts and fields: TitlePart: Provides a title for the blog post. AutoroutePart: Provides a URL for the blog post. BodyPart: Provides a rich text editor for the blog post content. MediaLibraryPickerField: Provides a way to select an index image for the blog post. Now take a look at what we have in Orchard Core. We have TitlePart and AutoroutePart in Orchard Core too, so that is handy, but there is no BodyPart and MediaLibraryPickerField. But after some research, we can find the equivalent of them: HtmlBodyPart and MediaField. We have all the parts and fields in the new CMS to recreate the BlogPost content type. In this example, we are creating it with the help of a migration file BlogPostMigration.cs: using OrchardCore.Autoroute.Models; using OrchardCore.ContentManagement.Metadata; using OrchardCore.ContentManagement.Metadata.Settings; using OrchardCore.Data.Migration; using OrchardCore.Html.Models; using OrchardCore.Media.Settings; using OrchardCore.Title.Models; namespace MyProject.Migrations; public class BlogPostMigration : DataMigration { private readonly IContentDefinitionManager _contentDefinitionManager; public BlogPostMigration(IContentDefinitionManager contentDefinitionManager) => _contentDefinitionManager = contentDefinitionManager; public int Create() { // Define a part called BlogPost with some fields. _contentDefinitionManager.AlterPartDefinition("BlogPost", part => part .WithField("Image", field => field .WithDisplayName("Index Image") .WithPosition("0") .WithSettings(new MediaFieldSettings { Multiple = false, })) ); // Define a type called BlogPost with some parts. _contentDefinitionManager.AlterTypeDefinition("BlogPost", type => type .DisplayedAs("Blog Post") .Creatable() .Listable() .Draftable() .Versionable() .Securable() // Add the Title part to provide a title for the blog post. .WithPart(nameof(TitlePart), part => part .WithPosition("0")) // Add the BlogPost part to provide some fields for the blog post. .WithPart("BlogPost", part => part .WithPosition("1")) // Add Autoroute part and configure it to use a pattern based on the title. .WithPart(nameof(AutoroutePart), part => part .WithPosition("2") .WithSettings(new AutoroutePartSettings { Pattern = "{{ ContentItem | display_text | slugify }}", })) // Add the HTMLBody part to provide a rich text editor for the blog post content. .WithPart(nameof(HtmlBodyPart), part => part .WithPosition("3") .WithEditor("Wysiwyg")) ); return 1; } } …and don’t forget to add your migration to the Startup.cs file to register it. However, if you have a content type with custom fields and parts, with custom functionality, and features, you will also have to recreate those fields and parts by reimplementing your custom code in the new project. Migrating content items The best way to add numerous content items is with a recipe. To migrate the content items, first, make sure that you have the content type created in the new system. After that, you will need to export your content items. The file formats of the recipes are different in the new CMS: Orchard 1 uses XML, while Orchard Core uses JSON, however, their functionality and use cases are similar. You will need to create an Orchard Core recipe: This can be done either manually, or Lombiq has a feature for this in the open-source Helpful Extensions module called Lombiq Helpful Extensions - Orchard 1 Recipe Migration. It has built-in functionality for content items with the most used content parts, but you can extend the built-in functionality to support more parts. Conclusion Migrating from Orchard 1 to Orchard Core is a challenging but rewarding process that can bring many benefits to your site. However, it requires careful planning, preparation, and testing to ensure a smooth transition. We have extensive experience and expertise in migrating sites from Orchard 1 to Orchard Core, and we can help you migrate your project. Lombiq has recently renewed and migrated its main site http://lombiq.com to Orchard Core too, and we are very happy with the results. You can check out our site and see how Orchard Core can power your site too. Happy migrating!

Delivering a Node.js asset pipeline as a NuGet package

How long does it take you to set up a Node.js-based frontend asset pipeline? That lints and compiles your SCSS, JavaScript, Markdown? That makes code style inconsistencies a tale of the past? In .NET? With Lombiq Node.js Extensions, it'll take you under a minute. In this post, we will provide an overview of what we’ve squeezed into Lombiq Node.js Extensions, how we packaged it for NuGet, why we ditched Gulp, and some gems on MSBuild integration. If you want to see a demo of Lombiq Node.js Extensions in action, check out our recent This week in Orchard post. Web Development in 2023 needs Node.js Even in the .NET world, Node.js has become a first-class citizen for all matters frontend. Grunt, Gulp, Babel, Webpack – all Node.js-based tools – have conquered the frontend landscape. Orchard Core uses Gulp to build its modules’ assets. At Lombiq, we used to use Gulp to build our assets. But it's... Time to say goodbye While Gulp provides a great development experience, there are downsides: Gulp wrappers around NPM packages were not always available or up to date. Sometimes, they caused unexpected errors after updates. Lack of support for Node.js 14 and above became an issue. Plain NPM and Node.js scripts can do the same work as a Gulp script. One less moving part in our tooling ecosystem means less friction. Based on experience with our Gulp Extensions project, we've built a tool that eliminates its weaknesses. Building a reusable frontend asset pipeline on top of Node.js Why? - So you can simply plug it into your projects. Like we do! How? - Read on! What? - Here's an excerpt of what Lombiq Node.js Extensions does: lints SCSS, compiles, autoprefixes and minifies it, generating source maps on the way lints JS, minifies it, generates source maps lints Markdown provides sensible defaults for Orchard-based web development, i.e. needs no manual configuration in the default scenario! can copy assets to a webroot folder, like image files and frontend libraries is usable from a NuGet package integrates tightly with MSBuild adds generated assets to the project's assembly allows to keep generated assets excluded from version control uses PNPM to efficiently install packages and execute scripts (if you don't know it, PNPM is a Node.js package manager with a lot of advantage over NPM) The important pieces Let's look at some of the magic sauce that makes all this possible! MSBuild takes care of the build We use our Lombiq NPM MSBuild Targets project to hook the necessary Node.js work into the MSBuild build pipeline. All the asset manipulation happens before a project's Compile target executes. That allows us to generate frontend assets and embed them into the project's assembly as part of the .NET build. There was a challenge here, though: Files that are generated during the build need to be added manually to the EmbeddedResource item group, else they won't be embedded in the DLL. Here's the relevant piece from the AddGeneratedFilesToEmbeddedResourceList target in Lombiq.NodeJs.Extensions.targets: <ItemGroup> <EmbeddedResource Include="@(NodeJsExtensionsTargetFiles)" WithCulture="false" Type="Non-Resx" /> </ItemGroup> Node.js complexities are handled under the hood Setting up Stylelint, ESLint, Markdownlint and other NPM packages can be time-consuming and complex. Lombiq Node.js Extensions has it all set up and configured out of the box! When your project integrates Lombiq Node.js Extensions and you accept the defaults, you are done. Installation and execution of the SCSS and JavaScript pipelines happen automagically. You even get live ESLint support in Visual Studio with our preconfigured settings! And if you need, you are free to extend them. Packing it up with NuGet Configuring NuGet packaging can be tedious, but here's our successful configuration. Most of all, we include all the files that are necessary to later install this project as an NPM package in any consuming project. As the documentation states: A package [can be] a folder containing a program described by a package.json file. Using Lombiq Node.js Extensions from a NuGet package is the simplest way to get started. When using it from a Git submodule, you will need to edit your project file. Outsource your frontend asset pipelines Are you still writing CSS, because you don't want to invest in setting up the necessary tooling to compile SCSS as part of your build? Do you still argue over your JavaScript files' code styling? Is inconsistent Markdown formatting plaguing you? Let Lombiq Node.js Extensions handle all that for you. Get the NuGet package today! Should you need any further help, file an issue or contact us for commercial-grade support.

Our full Orchard Core tutorial series, the Dojo Course 3 is here!

After a long wait, the new Orchard Core version of our legendary Dojo Course tutorial series is here, the Dojo Course 3! Are you a newcomer and want to learn Orchard Core from the ground up, both from a user's and a developer's perspective? Are you somewhat familiar with Orchard Core but would like to get up to speed and become an Orchard pro? Look no further, check out Dojo Course 3! Dojo Course 3 guides you from the very basics of Orchard Core all up to be able to write your own themes and modules, utilizing various APIs of Orchard. We're publishing a tutorial video every day for 40 days starting on 1 December. So, this is your 40 days of Orchard :).