This week in Orchard - 10/19/2018

This week in Orchard

In the current post we would like to summarize you the latest amazing demos around Orchard Core!

On Orchard Core

Demos

File Content Definition Feature

How to handle content type definitions when you have multiple people working on the same project? The fact that when you create a content type and when you are on the deployment, you have to copy the database on all the dev machines. Or even if one dev adds a content type you have to share the database or create new recipes and rerun the recipe.

A good solution could be to use a file to store the content type definitions. The nice thing with a file is that you can put it in a repository and then when you update it just update all the content definitions that in the file. For that there is a new notion in the OrchardCore.ContentManagement module: IContentDefinitionStore. The IContentDefinitionManager lets you list types/parts and updates them. The new IContentDefinitionStore interface actually stores the content definition with the LoadContentDefinitionAsync and SaveContentDefinitionAsync methods.

The default implementation called DatabaseContentDefinitionStore that uses YesSql to store the document. Now there is a new one called FileContentDefinitionStore, which will read and store a JSON file. So instead of using a database, this JSON document will put in a file. This is defined as a new default feature in the OrchardCore.Contents module and the FileContentDefinition is also in a separated feature.

You can find the ContentDefinition.json file in the App_Data/Sites/Default folder with the following content:

Here we added a new content type, for example MyContentType and adding a new TextField to it, we will see the ContentDefinition.json updated with the definition of this content type. It's because in the modules we enabled the module called File Content Definition that stores content definition in a local file.

You can test this new feature in the dev branch of Orchard Core.

Taxonomies leaf support

First don't forget to enable the Taxonomies module. Then let's create a new content type, called Color. The Color only just has a Title. Now create new Taxonomy under the New menu. Let's add a name Colors and select Color as the Term Content Type. Now here we can add new Colors.

Now add a Taxonomy Field to a content type. In our example we added a new Taxonomy Field called Colors to the Article content type.

Here you can see a checkbox with label: Check if only the leaves of the taxonomy can be selected. Let's put a tick here.

Now let's create a new Article with some selected colors. For example, select the Dark Blue and Light Red values.

Now open the YesSql database of our site. In the TaxonomyIndex table you can see two new rows. These two records are for the two selected terms. What we have here is the TaxonomyContentItemId, that is the ID of the Colors taxonomy. The ContentItemId is the Article content item ID. The TermContentItemId is the ID of the term that is selected.

Now we can query taxonomy elements and this schema could make it very easy to do that: you can query and filter by specific content parts, content types, content fields and so on.

There are some Razor extensions in the TaxonomyOrchardHelperExtensions.cs file: get the taxonomy term by its ID, get inherited terms by their ID and to query the taxonomy index directly.

You could find the improvement in the branch called taxonomies.

Using a workflow to make the Contact Us form of the Agency theme dynamic

The Contact Us form of the Agency theme doesn't do anything, it's just had a frontend to show how to design a form like this.

Antoine Griffard decided to make it dynamic by using a workflow. He used an Http Request event with a HTTP POST method as the starting activity of the workflow called Contact Form Submitted. Here you can see the full workflow.

Don't forget to watch the recording of the latest Orchard Podcast for the full demos!

No Comments

Add a Comment