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

Featured tags

IIS
API
SMS
SEO
All tags >

Migrate INotifier to support async implementations, Lombiq Hosting - Tenants - This week in Orchard (28/09/2021)

Migrate INotifier to support async implementations, messaging when getting Part InvalidCastException, Lombiq Hosting - Tenants demo, and many more coming this week! Do you want to know more? Then don't forget to check out our current post! Orchard Core updates Migrate INotifier to support async implementations This new feature is about replacing the INotifier on the front end with a SignalR version, which works asynchronously. INotifier has been updated to use ValueTask when adding notifications. Prefer not to do a custom implementation, as using INotifier allows the front end to also receive messaging notifications from code in the Orchard Core codebase, which is very convenient for us. If you check out the INotifier interface, you will notice that the Add method is now marked as obsolete, and the new one that you can use from now is the AddAsync one. And of course the Information, Warning, Error, Success extension methods are also marked as obsolete and have their async methods, which are used across the whole solution of Orchard Core. Messaging when getting Part InvalidCastException Sometimes if you forget to register your part, you might have some cast errors, and you don't know why. This addition is just about displaying an error message saying you are trying to cast to this part, but please do a double check to make sure you registered this part. So, don't forget: every time you create a new content part from your module, you have to register it in the ConfigureServices method of your Startup class by using the AddContentPart extension method. You can find several examples about how to do that like, here you can find the registration of the FlowPart and the BagPart. DisplayText value of a cloned item is set before calling CreateAsync When cloning a content item, two audit log events are recorded: An initial create event for the newly cloned item. A subsequent save event updating the new item with the cloned content data. The create event in the audit log does not show the DisplayText of the original item but instead repeats the content type. The save event in the audit log displays correctly. Steps to reproduce the behavior: Set up a Blog site. Ensure the Audit Trail feature is enabled and configured to log all content items. Go to the Manage Content page and clone the About article. View the Audit Trail and see that the Create event states that Version 1 of the Article Article was created. The audit log for the created event should state that Version 1 of Article About was created. The fix was pretty straightforward for this one. As you can see here, the solution was to set the DisplayText of the cloned content item before calling the CreateAsync method of the DefaultContentManager, because the CreateAsync invokes the event handlers used by the Audit Trail module. Demos Lombiq Hosting - Tenants The Lombiq Hosting - Tenants repository contains various features that help you build a multi-tenant web application in Orchard Core. With the help of the Tenants Management module, you can set restrictions on tenant creation, while using the Tenants Admin Login module you can log in from the Default tenant's admin dashboard to any other tenants as an administrator user. In this demo, we will go with the quicker way and use our Open-Source Orchard Core Extensions full Orchard Core solution that contains both of these modules. 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 Hosting - Tenants Admin Login module that adds the ability to log in as a tenant's admin user. Make sure that you have also enabled the Tenants module to be able to test the tenant management. :) Now create a new tenant and enable the Lombiq Hosting - Tenants Admin Login - Sub-tenant feature there that adds the ability to log in to the tenant from the Default tenant. That will mean that admin users from the Default tenant can log in to this tenant as an admin user. In our example, we have created a tenant called Blog, and if you Edit that tenant, you will see a new Login as an admin user button, which can be used to login to this tenant as an admin user. Now let's see what you can do by using the other module of the Lombiq Hosting - Tenants repository, called Lombiq Hosting - Tenants Management which manages restrictions on tenant creation. The Readme.md file of the Tenants Management module shows how you can specify a list of hostnames that cannot be used to create a tenant. You can write the list of forbidden hostnames as a JSON array in the appsettings.json as follows. Now let's go back to the Tenants page of the admin UI and try to create a tenant with a forbidden hostname like forbidden.hostname1.net. If you hit Create, you will get a validation error: forbidden.hostname1.net is a forbidden hostname. And of course, changing the hostname of an already running tenant to a forbidden one will also cause a validation error. And as always, if you would like to see more, don't forget to check out this recording on YouTube! News from the community A new website using Orchard Core: ICAgile ICAgile envision a world in which organizations enable and inspire everyone in them to create a better future for those around them. Check out this brand new Orchard Core site here! If you are interested in more websites using Orchard and Orchard Core, don't forget to visit Show Orchard. Show Orchard is a website for showing representative Orchard CMS (and now Orchard Core) websites all around the internet. It was started by Ryan Drew Burnett, but since he doesn't work with Orchard anymore, as announced earlier it is now maintained by our team at Lombiq Technologies. Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 226 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! If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

New Content-Language HTTP header feature, LINQ to DB - This week in Orchard (21/09/2021)

Add Content-Language HTTP header feature, new Health Check option, LINQ to DB demo, and many more coming this week! Do you want to know more? Then don't forget to check out our current post! Orchard Core updates Add Content-Language HTTP header feature While the Accept-Language header is useful for the request, Content-Language is very useful too for the response, there's no support for this yet. But that was the past! Now if you head to the admin UI of your Orchard Core and navigate to Configuration -> Features, you will find a new feature called Content-Language header that adds the Content-Language HTTP header, which describes the language(s) intended for the audience. Let's enable this module and see it in action! In this case, we just open up the DevTools of Google Chrome, click on the Network tab and check the content of the Headers tab after loading a page with a content item. In our case, we opened the home page of the tenant called blog1. As you can see, the Content-Language header is there containing the language of the given content, which is en-US in our case. Add Health Check options The option here is to be able to change the default URL of the Health Check. The health/live is the default one provided by ASP.NET. If you enable the Health Check feature and navigate to an URL like https://localhost:44300/health/live you will see the status of your site. And now, you can easily change the value of this URL by just updating the value of the URL of the OrchardCore_HealthChecks section in the appsettings.json file. Allow custom editors for Bag/Flow/WidgetsList Parts If you checked the drivers of the BagPart, FlowPart, or the WidgetsListPart, you would notice that these drivers were using hard-coded shapes, and now you can have custom editors based on the editor name, and you can select it. The default editor for these drivers is called Standard. Demos LINQ to DB - Lombiq Helpful Libraries for Orchard Core The LINQ to DB subproject is part of our Helpful Libraries project that contains various libraries that can be handy when developing for Orchard Core CMS, to be used from your Orchard modules. The use-case is that sometimes you just have to go to SQL. Although we have YesSql, we have all the abstractions, but of course, the SQL connection is still there if you want to go low level. Sometimes you have to write some funky query there, or otherwise, you just want to store something in the database which is not a content item, not necessarily an entity, just a simple table with some simple rows. And in that case, you may not want to write like SQL queries as strings. But still, you don't want to use a full-blown ORM like Entity Framework because that would be a bit of an overkill for use-cases where you don't need a full-blown application built on it. And for such cases, there is a library called LINQ to DB, which is a third-party library. LINQ to DB is the fastest LINQ database access library offering a simple, light, fast, and type-safe layer between your POCO objects and your database. What we have implemented in our project is that by just hooking into ISession (which is the standard YesSql ISession), you will get to write queries like this: There is a helper method, and in there you can pretty much write LINQ against tables. In this case, we are using the AutoroutePartIndex as the example, and as you can see it's LINQ as usual but since you are wrapped into this LingQueryAsync, the inside of it is executed as SQL directly. And as always, if you would like to know more about the LINQ to DB subproject, head to YouTube for a recording! News from the community A new website using Orchard Core: Planters Products Inc Planters Products, Inc. was established in 1963 as one of the leading Agricultural Chemical Companies in the Philippines. In 1970 it was purchased by the Sugar Producers Cooperative Marketing Association, the country's largest cooperative of sugar planters, and renamed Planters Products, Incorporated (PPI). Check out this brand new Orchard Core site here! If you are interested in more websites using Orchard and Orchard Core, don't forget to visit Show Orchard. Show Orchard is a website for showing representative Orchard CMS (and now Orchard Core) websites all around the internet. It was started by Ryan Drew Burnett, but since he doesn't work with Orchard anymore, as announced earlier it is now maintained by our team at Lombiq Technologies. Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 224 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! If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

Rules module, Html Menu Item - This week in Orchard (21/03/2021)

This time you can read about the new Html Menu Item content type, you could see how to use the new Rules module, and can watch a recording about a new Orchard Core theme! Check out our post for more! Orchard Core updates Add new HTML Menu Item content type This is a new content type that is super useful for menus that are customized like you have items that are links but there is one item with a special div or with a custom HTML to provide like images and stuff inside. Let's take a look at the HtmlMenuItemPart. Using that part you can just edit the Row HTML directly. The content here is sanitized by default to prevent custom scripts, but if you navigate to Content -> Content Definition -> Content Types -> Html Menu Item and hit the Edit near the Html Menu Item Part you can disable the sanitization anytime. On the screen below you can see the new HtmlMenuItemPart Content Part and the liquid file that is responsible to render its content when using the Blog theme. But let's see how you can use this content type in your site! Let's say you set up your site using the Blog recipe. By using the Blog recipe you will get a default menu, called Main Menu, that contains two Link Menu Items, called Home and About. The first one is just about redirecting the user to the home page and the second one is about redirecting the user to the slug of the built-in About Article. Now head to the Main Menu option of the admin menu and click on the Add Menu Item button to add a new Menu Item. Here you can see the new option that you can select: the Html Menu Item. Select this one and fill out the form. The Url will be the target link where the user will be redirected when clicking on this menu item. And the Html box will contain the custom HTML of our menu item. Here we are just using the HTML code from the Category terms of the Blog Post and modified it a little. And we put this new menu item between the two existing ones as you can see here. And one last note here. When you add a name to your menu item (you saw we used the My new Html Menu Item just for the sake of demonstration) it will be persisted in the string property called Name that is available on any existing parts that can be used as a menu item (LinkMenuItemPart, ContentMenuItemPart, and MenuItemsListPart). But you cannot see the Name property when you check out the implementation of the HtmlMenuItemPart. The reason for that is the Name property is obsolete and will be removed in a future version and you should use the DisplayText instead. And as you can see, the MigrateMenuItems method in the Migrations.cs of the Menu module is just about to migrate the existing menu items to use the DisplayText property instead of the Name. jQuery 3.6.0 released and added to Orchard Core jQuery 3.6.0 has been released! In jQuery 3.5.0, the major change was a security fix for the HTML prefilter. This release does not include a security fix but does have some good bug fixes and improvements. If you want to read about this new version, head to this post now! But now let's focus on the fact that you can also use this new version of jQuery in your custom themes or modules by default without the need of including it by yourself. If you open up the content of the OrchardCore.Resources module, you will find the ResourceManagementOptionsConfiguration.cs file there which is responsible to register some scripts and stylesheets for you by default that you can easily use anytime you want. So, from now we have several jQuery versions that you can use in Orchard Core, like version 3.6.0, 3.5.1, and 3.4.1. You can specify which version you want to use but if you don't do that, the CMS will inject you the newest one. Demos Rules module Using layers in Orchard Core was not a good idea because every time someone would like to use layers, the members of the community always said to don't do that, layers are too slow. But layers are really useful and the good news is the performance of the layers is now much better. Let's see the topic of this demo, the Rules module which allows you to build rules for the layers without using JavaScript. What you have now if you edit a layer, you have rules that you can add to a layer with a nice little popup. The easiest one is the Always layer, which has a boolean condition of true or you can choose to be false if you never want to show the widgets in this layer. You can also have two types of groups: All condition group, which means all of the rules inside this group should be true. Any condition group, which requires one condition to be true. The easiest way to show how grouping work maybe is to go with a GIF. Here you will see that we are creating an All condition group layer rule and inside that group, we have a Content type condition and a URL condition. We say that we only want to display the content of this layer if the content type of the currently displayed content item is BlogPost and if the URL contains the blog word. So our layer will not be visible if the URL just contains the blog word, we need a BlogPost content item to be displayed too. But you don't really need the all condition group here. If you just put the layer rules without using groups, the layer will be visible only if all the conditions here return true. If you want an OR behavior, use the any condition group layer rule. And one cool thing here: you can use drag and drop to move the rules between the groups. You can easily say that I want to move this outside from the all conditions group and put it into the any conditions group. And don't worry if you prefer the JavaScript conditions, you can still add a JavaScript condition where the script must return true or false to display or hide the content of the layer. And as usual, in Orchard Core everything is extensible. If you would like to add your own custom layer rules you can easily do that just by implementing the ConditionEvaluator abstract class where the EvaluateAsync method is responsible to return a boolean value that represents the result of your rule. Check out an easier one, like the HomepageConditionEvaluator! And as usual for the demos, if you would like to know more about this awesome new feature, don't forget to head to YouTube for a recording! Tailwind Blog Theme If you navigate to the following repository on GitHub you will find a simple blog template built with Tailwind and AlpineJS. Tailwind is a utility-first CSS framework packed with classes like flex, pt-4, text-center, and rotate-90 that can be composed to build any design, directly in your markup. Here you can see what kind of classes you need to add to be able to handle the margins, colors, the font-size, and almost everything. Tailwind doesn't give us automatically pre-styled components. Rather, it gives us utility classes that help us style our components in certain ways and allows us to build our own classes using these utility classes. In the following recording, you could see how you can build a blog theme in Orchard Core using the Tailwind blog template. News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 194 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 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! If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

Why is my content part not recognized in Orchard Core? - Orchard Core Nuggets

You have implemented your MyAwesomePart but you cannot attach it to your content type using the dashboard because it's not showing in the Content Parts list (Content -> Content Definition -> Content Parts)?The most possible reason for this that you haven't registered your implementation in the service container. To register your class in the service container head to the Startup.cs file of your module and in the ConfigureServices method add the following line: services.AddSingleton<ContentPart, MyAwesomePart>();But if you are using the RC1 version of Orchard Core or newer you can use the AddContentPart extension method, where you just only need to provide your content part: services.AddContentPart<MyAwesomePart>();. The AddContentPart and the AddContentField (that you can use to register your fields) can be found in the OrchardCore.ContentManagement namespace.Another recommendation is to use the Part suffix when naming your class or cs file that contains your custom part. Don't forget to put it in a Models folder to follow the recommendation of the MVC (model-view-controller) software design pattern.For more information about registering your Part check out the Startup.cs file of our Orchard Core Training Demo module, where we registered the PersonPart in the service container. We also mentioned the new way of registering ContentParts and ContentFields in this post of our This week in Orchard series. 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!

Diving into the Orchard API - Dojo Course

UPDATE (2017-11-22): Dojo Course 2 is released with new, updated videos! This week on Dojo Course we dive into the Orchard API, use some of the build-in services and extending the capabilities of our module to make it even better! Using LazyField<T> to load data lazily so they are only loaded when we really need them. Using Work<T> to load dependencies lazily so they are only resolved when we really need them. Applying the [Admin] attribute for admin-related Getting to know an other Orchard service: IAuthorizer. Creating our own permissions by implementing the IPermissionProvider. Using the ContentManager so we can finally work with content items! Generating ad-hoc shapes and matching them to an actual template. Implementing the IResourceManifestProvider interface for managing static resources. Remember: if you have any questions don't hesitate to ask them by creating a new issue in the Orchard issue tracker with the "discussion" label. Make sure to prefix your thread's title with "Dojo Course - "! We keep an eye on these issues. Also follow us on Twitter to get notified about the latest Dojo Course news, including when a new tutorial is posted. Do you have some feedback about the course? Please send it in. Haven't you enrolled yet? Why not do it some time in the near future like right now?

Content Part development continued - Dojo Course

UPDATE (2017-11-22): Dojo Course 2 is released with new, updated videos! This week on Dojo Course we are giving life to our content part by adding several Orchard-y code pieces to it, though the result is far from being Frankenstein-like. While doing that, we also discover some interesting and useful pieces of the Orchard API. Creating a migration for our Contents feature. Difference between ContentPartRecord and ContentPartVersionRecord: versioning content parts. Making your content part attachable to content types (on the Admin UI). Creating a content type using migrations and attaching parts to it. Creating a handler for our content part to do some plumbing (e.g. StorageFilter). Creating a driver for our content part to cover server-side part of the the user interface interaction. How displaying a shape works, what is DisplayType? Shape templates (also editors) and using Placement. Using InfosetPart to store a part's data in the content item's XML infoset document. This eliminates content part record lazy loading, providing a significant performance gain. The importance of driver shape factories. How to make your content part support importing and exporting? Remember: if you have any questions don't hesitate to ask them by creating a new issue in the Orchard issue tracker with the "discussion" label. Make sure to prefix your thread's title with "Dojo Course - "! We keep an eye on these issues. Also follow us on Twitter to get notified about the latest Dojo Course news, including when a new tutorial is posted. Do you have some feedback about the course? Please send it in. Haven't you enrolled yet? Why not do it some time in the near future like right now?

Forum favourites: records, database indices and about the necessity of drivers

Forum topics from the Orchard discussion board that we found interesting: "Record persisting advices": checklist if you want to store something in a low-level (non-content part) record "Adding empty part to type fails": always create a driver for your part "Records only in Models namespace: good?": remember to put your records under the Models namespace "Indices with SchemaBuilder": you can add database indices from migrations, but only from AlterTable