Include or exclude tenant features and/or themes, allow editing Time Field seconds and milliseconds - This week in Orchard (07/09/2021)

Gábor Domonkos's avatar
Admin UI, Documentation, This week in Orchard, Content field, Recipes, Resource manifest

Allow to edit Time Field seconds and milliseconds, document dependency version selection in ResourceManagementOptionsConfiguration class, demo about a feature to include or exclude tenant features and/or themes, and many more coming this week! Check out our post for more!

Orchard Core updates

Document dependency version selection in ResourceManagementOptionsConfiguration class

Let's say that in the theme layout, you want to enforce Bootstrap 4.6 and added this <script asp-name="bootstrap" version="4" at="Foot"></script> which includes Bootstrap 4 as desired.

Now let's have a custom module that allows converting a select-menu to a searchable-menu. This module depends on Bootstrap and jQuery to be able to function. So in the ResourceManagementOptionsConfiguration class, we need to define the dependencies like this:

    .SetUrl("~/SearchableDropdowns/bootstrap-select.min.js", "~/SearchableDropdowns/bootstrap-select.js")
    .SetDependencies("jquery", "bootstrap")
    .SetUrl("~/SearchableDropdowns/bootstrap-select.min.css", "~/SearchableDropdowns/bootstrap-select.css")

Unfortunately, the SetDependencies("bootstrap") call here forces to include Bootstrap 5, which will cause Bootstrap 4 and 5 to be included! Obviously, this is a problem.

But you can easily solve this problem. You can use the SetDependencies method to ensure the script or style is loaded after their dependency, where you can set a specific version of your choice or the latest version available. Check out this new section in the Orchard Core documentation where we used SetDependencies("bootstrap:4") to say that we would like to define a style that depends on Bootstrap version 4.

SetDependencies with version number

Allow editing Time Field seconds and milliseconds

Let's take a quick look at the improvements of the Time Field. In our example, we have set up our Orchard Core site using the Blog recipe and modified the content definition of the Blog Post content type by adding a new Time Field to it. When you navigate to the settings of the Time Field, you will see a new setting here, called Step.

Step option for Time Field

This is just about manipulating the value of the step attribute of the time input type. You can read a lot about the step attribute here, now we just want to show you a small example of how you can use this new option.

Let's say we want to allow to be able to edit the seconds for the Time Field too, but not the milliseconds. If we type 15 for the Step here, users can choose from the following values when setting the seconds: 0, 15, 30, and 45. It means, setting the value of this field to 03:39:15 PM would be suitable. If the user would like to create a new blog post and enter an invalid value for the Time Field, they would see the following message by showing some suggestions about the nearest valid values.

Time Field validation

Do not enable OrchardCore.Feeds by default in standard recipes

By default by enabling the OrcardCore.Feeds module your lists will have feeds capabilities but for the Blank and the Agency recipe. This doesn't make any sense because we don't have any lists defined by default in these recipes. The change here is the Blank and the Agency recipes now will not enable the Feeds module by default.

Do not enable the Feeds module in the Blank and the Agency recipes


Include or exclude tenant features and/or themes

This upcoming feature is about through app settings/configuration adds the ability to restrict the features and/or themes that are available to either a tenant and/or all tenants or a mix of both.

If you checkout to the deanmarcussen/excludefeatures branch, you will see a new OrchardCore_Features section in the appsettings.json file where you can see rules that you can apply to the various features. The idea here is that you can have the rule to either exclude or include a given expression based on the feature name. By default, the OrchardCore.Templates feature and the TheAgencyTheme are excluded for all tenants, but the default tenant has an include rule with a "*" expression which means that tenant gets everything.

Features configuration in appsettings

Now let's see this in practice! Let's set up a site using the Software as a Service recipe to get the Tenants feature enabled by default. If you navigate to Configuration -> Features on the admin UI, you will see that the Templates feature is available with the TheAgencyTheme as well (Design -> Themes).

But if you have a tenant called blog1 and search for templates on the Features page, you will only find the Shortcode Templates one because the Templates feature is excluded for this tenant. And the same will apply if you navigate to Design -> Themes and try to find The Agency Theme.

Excluded Templates feature

A nice additional feature would be to have a UI, where you can specify what kind of features and/or themes would like to exclude or include for the given tenant. But we are just scratching the surface of this upcoming feature. If you would like to know more, don't forget to head to YouTube for a recording to learn more!

News from the community

Helping the City of Santa Monica with Orchard Core consulting

A few weeks ago we mentioned a new website using Orchard Core: the site of the City of Santa Monica, which you can find on Show Orchard as well! 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.

Santa Monica is a beachside city of 8.3 square miles on the westside of Los Angeles County. Offering an environment of unparalleled natural beauty, the city is home to a mix of residential communities, commercial districts, and recreational venues. And we actually had a small part in this by helping the creation of this site with some Orchard Core consulting. If you would like to know more, check out the case study on our site here.

City of Santa Monica Orchard Core case study

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!

No Comments

Add a Comment