This week in Orchard - 12/20/2019

Gábor Domonkos's avatar
Admin UI, This week in Orchard, Role, Permission, Workflows, Recipes

Custom parameters support in recipes, new Retrieve Content task, improved Roles UI, a new post about Orchard Core, demos about the Open Tags and the headless recipe for Orchard Core! Should I continue? Many news is waiting for you in our current post and for closing, we would like to show you some nice pics about our Christmas event!

On Orchard Core

Custom parameters support in recipes

From now you can set custom parameters in the appsettings.json file that can be passed and used in a recipe. As you can see in the documentation, you can access a parameter value like [js: configuration('CustomParameterKey')]. For this, there is a new ConfigurationMethodProvider that receives the ShellSettings and retrieve the value to replace by ShellSettings.ShellConfiguration["CustomPropertyKey"].

Add version and target framework variables in .props

Hisham Bin Ateya refactored the Dependencies.AspNetCore.props file and created a new variable named AspNetCoreTargetFramework, which contains netcoreapp3.0. Now when there will be updates on ASP.NET Core we just only need to pick this up more easily. This will simplify the process when we need to update the AspNetCore version. Here is a snippet from the Dependencies.AspNetCore.props file:

<Project>
<PropertyGroup>
<AspNetCoreVersion>3.0.0</AspNetCoreVersion>
<AspNetCoreTargetFramework>netcoreapp3.0</AspNetCoreTargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageManagement Include="Microsoft.AspNetCore.Authentication.AzureAD.UI" Version="$(AspNetCoreVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Authentication.Facebook" Version="$(AspNetCoreVersion)" />
<PackageManagement Include="Microsoft.AspNetCore.Authentication.Google" Version="$(AspNetCoreVersion)" />
...
</ItemGroup>
</Project>

And here is a snippet from one of the modules where we use the AspNetCoreTargetFramework variable:

<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>$(AspNetCoreTargetFramework)</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
</PropertyGroup>
...
</Project>

New Retrieve Content workflow task

There is a new task called Retrieve Content that tries and evaluates a content item ID from a JavaScript expression if provided. Let's see a sample workflow that has this new task in it.

Here we have an HTTP Request Event as a start activity that creates a blog post that has a DisplayText: My blog post using the Create Content Task when someone invokes the URL with a GET method. The Create Content Task sets the WorkflowExecutionContext.CorrelationId (the correlation ID can be used to resume workflows that are associated with specific objects, such as content items) with the newly created content item's ID. As we mentioned, the Retrieve Content Task accepts a JavaScript expression, so here we used the correlationId() method to get the ID.

The Retrieve Content Task returns the content item by it's ID and sets the WorkflowExecutionContext.LastResult with the retrieved content item. Now by adding a Notify Task, we can use a Liquid expression to display the DisplayText property of the newly created blog post content item. Finally, make a redirect to the admin page using an HTTP Redirect Task to see the displayed notification.

Using custom admin URLs

There is a new AdminOptions defined in the OrchardCore.Admin.Abstractions module. It tries to configure the prefix of the admin URL from the configuration and then it's creating a property called AdminUrlPrefix that is by default admin. You can change the prefix for all the admin pages. All you need to do is to add the following section to appsettings.json inside the section called OrchardCore:

"OrchardCore.Admin": {
"AdminUrlPrefix": "dashboard"
}

When you are creating a route to your AdminController, don't forget to change the route template of your controller to use this prefix like in the following snippet, which code can be found in the OrchardCore.AdminMenu module.

public override void Configure(IApplicationBuilder builder, IEndpointRouteBuilder routes, IServiceProvider serviceProvider)
{
// Menu
var menuControllerName = typeof(MenuController).ControllerName();
routes.MapAreaControllerRoute(
name: "AdminMenuList",
areaName: "OrchardCore.AdminMenu",
pattern: _adminOptions.AdminUrlPrefix + "/AdminMenu/List",
defaults: new { controller = menuControllerName, action = nameof(MenuController.List) }
);
...
}

Roles UI and default description

We have role descriptions, but the default roles don't have any descriptions. This opens a great opportunity to improve the UI of the index and the edit pages of the Roles. In the index page, you can find the description of every role under its name and the Search box with a new UI.

When you add a new role you can set its name and description. And when you edit an existing one, you can also edit its description. Here you can also find some hints about what is the difference between the Allow and Effective permissions.

New post: Lucene, GraphQL and Orchard Core

Sipke Schoorstra has published a nice article again in medium.com to guide people on how to implement Search using Orchard Core, Lucene and GraphQL. Read his interesting and easy to follow article about how to enable Lucene, set up a Lucene Query and consume the available APIs from Postman using Lucene and GraphQL, allowing us to use a consistent API from our applications.

Demos

Orchard Core headless recipe

The idea of the headless recipe is to provide a recipe that sets up GraphQL, queries, and everything that has an API interface and restrict the interface down a little bit. The recipe has no home page, so when you set up your site using the recipe, you will see the login page first. And in the admin page, you will see only those options in the menu, that are related to the API interfaces.

You can also watch a great detailed demo on YouTube about what will you get if you install your site using the headless recipe!

Orchard Core Open Tags

Last month you could see a great demo about how to work with tags using taxonomies in Orchard Core. Here we mentioned that when you add a taxonomy field to a content type with a Tags editor type and you type something in the field, you can't create a new tag that should be added to the list of tags, because that feature was under development that time. Now thanks to Dean Marcussen this is not an issue anymore. Let's see how he solved this problem!

We have a site with the Blog recipe installed. Add a taxonomy field called Tags to the Blog Post content type using a Tags taxonomy with a Tag content type that has just a simple Title Part. Here use the Tags editor type with the Tags display mode. And here you could notice a new checkbox, called Open. As the hint says, if you put a tick here, you can create tags inline when editing or creating blog posts. Put a tick here and let's edit the predefined blog post!

When typing something in the Tags editor and hit enter (or just click on it), you can add new tags to the Tags taxonomy and to this blog post as well. If you edit the Tags taxonomy using the dashboard you will see that the new tag has been created and the title of that tag is the value that we have just entered when editing the given blog post.

If you checked the editor of the blog post well you could see that there is a section called Category with two radio buttons. But what are these for? The Category is also a taxonomy field added to the blog post with the standard editor and display mode. It uses the Categories taxonomy with the Category content type as the term.

But this time the content type that is used as a term is not just about having a Title Part, but it also has a Text Field with an Icon picker editor. This means when you add Category term content types to the Categories taxonomy you can also set an icon for this term. And if you override this shape using a Liquid template or a Razor view, you can display the Font Awesome icon near the name of the term!

You can also watch a nice demo on YouTube about the Open Tags for Orchard Core!

On Lombiq

Orchard Nuggets: How to use the same version of Orchard Core NuGet packages in every project across my solution?

You have your own ASP.NET Core project that using Orchard Core NuGet packages, but every time when you update them you have to do it one-by-one across the whole solution? In our second Orchard Nuggets post, we show you a way how to update the packages easily! Check out the other posts for more such bite-sized Orchard tips and let us know if you'd have another question!

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. Last week we had our last RnDay for this year in the Loffice Budapest, which is a coworking office with an event space where we held this event. And at the end of the day, we visited a nearby restaurant to have dinner together.

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 with some photos of our latest event!

Orchard Dojo Newsletter

Now we have 109 subscribers of the Lombiq's Orchard Dojo Newsletter! 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!

No Comments

Add a Comment