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 >

Lombiq .NET Analyzers, Shortcodes feature merged - This week in Orchard (04/09/2020)

We have mentioned the Shortcodes feature several times and now it's available in the preview packages of Orchard Core. We will also show a demo about how you can use our .NET Analyzers in your Orchard Core solution. Check out our post for more! Orchard Core updates Tabs syntax changed in the documentation Orchard Core documentation contains code samples both in Liquid and Razor languages. You can see the given code samples in tabs near each other. If you want to change between them you just need to click on the Razor or the Liquid tab to see the snippets. Now, if you would like to improve the documentation and put some snippet there too, you have to use a new syntax in Markdown. In the screen below you can see the old one in red, and the new one in green. Thank you for making the documentation better and better! Media root folder selected by default If you navigated to the dashboard of Orchard Core and opened the Media Library (Content -> Media Library) you may found that the images in the root folder were not available on the list on the right. The workaround was to create a new folder to see the files in the root. Now, this issue is fixed, the media root folder is selected by default and you are able to see the content in the media library without any workarounds. New icons for User Disabled and Enabled events A small UI change here. When you add a new User Disabled or User Enabled event to your workflow you will find new icons here. These icons are also used when you are working on your events on the kanban board of your workflows. Shortcodes feature merged Shortcodes are small pieces of code wrapped into [brackets] that can add some behavior to content editors, like embedding media files. The Image Shortcode can be used to display an image from the media library in your WYSIWYG editors. The simplest way to use that Shortcode is the following: . And the good news is that now you can find the Shortcodes and the Shortcode Template features in the preview packages of Orchard Core! In case if you missed you can find two videos on YouTube about Shortcodes: check out this one first, then watch this video for the second part of the demo! We also mentioned these features in This week in Orchard too several times. Check out this for an introduction, then this one for the first demo, finally don't forget to read this post to see the improvements of the Shortcodes! And the documentation is available in this URL! Update configuration documentation The documentation now contains more lines to explain how to read a configuration from an external config file, that you can use in your Startup class. Click here to see the updated page! New workflow task to validate user There is a new Validate User Task to check if the user exists for the current request and has the specified role(s). This task has three outcomes: InRole: if the user in the current request has at least one of the selected roles. Anonymous: if the user in the current request is anonymous. Authenticated: if the user in the current request is authenticated If you check the Set the 'UserName' workflow property if the user is authenticated checkbox, the username of the current user will be added to the Properties dictionary of the WorkflowExecutionContext that you can use in the upcoming tasks. Demos Lombiq .NET Analyzers Our Lombiq .NET Analyzers repository contains .NET code analyzers and code convention settings for Lombiq projects. We use these to enforce common standards across all our .NET projects, including e.g. in all of our open-source Orchard Core extensions. If you contribute to our open-source projects while using that solution you'll be guided by these rules too. There is a built-in code analyzer in Visual Studio, but there is a lot of other analyzer projects out there. These analyzers can find issues in your code, but this is about to extend that and try to find even more issues. The Readme.md file in the repository tells you how you can add these files to your solution in just two quick steps! Now let's see a simple example of this! Let's imagine that you have an interface with a method that represents an asynchronous operation. After we created our great interface with the method you will notice that the IDE complains about some stuff. First of all, we have an interface and a method in it with no documentation. The DoSomethingGreat method is an async method, so the correct name of the method would be DoSomethingGreatAsync. Pretty cool, right? But that's not all! Head to YouTube to see the full demo about Lombiq .NET Analyzers! News from the community Extending event handlers sample in the Lombiq Training Demo for Orchard Core Orchard Core Training Demo module is a demo Orchard Core module for training purposes guiding you to become an Orchard developer. You can use this module as part of a vanilla Orchard Core source that including the full source code - which is the recommended way. You can use it as part of a solution the uses Orchard Core NuGet packages, however, it's harder to look under the hood of Orchard Core features. The latest update of the module is about to show you how you can extend Orchard Core with event handlers. The LoginGreeting class is about to implement the ILoginFormEvent interface and shows a notification to the user after a successful login. Check out the code here! Orchard Core workshops The contributors of Orchard Core will hold some unique online workshops in September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 160 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!

Shortcodes improvements, Lombiq Training Demo updates - This week in Orchard (14/08/2020)

This week we see the latest improvements of the Shortcodes module and the new pages of the Orchard Core documentation! Don't forget about our Traning Demo module, which has now got a new RESTful web API sample! Check out our current post for more! Orchard Core updates Highlight invalid fields When you have a driver for your content part or for your content field, the UpdateAsync method will be called when you are about to save and persist the new values of it. Let's say you have a TextField and you want to set it to be required. In the UpdateAsync method of the TextFieldDisplayDriver, we get the TextFieldSettings and if the value of the Required property is true and the Text property of the TextField has no value, then it's time to show an error for the user. Notice the second parameter of the AddModelError method. This is about passing a key to the ModelStateDictionary. The key would be the value of the Text property of the TextField and the Prefix would be the BlogPost.Subtitle string. But why is it important right now? Because there was an issue in Orchard Core about the different highlightings. If there is a validation error, it would be great to highlight the input editor, not just showing the validation summary at the top of the form. So, imagine you have a site installed with the Blog recipe and you set the Subtitle TextField of the Blog Post content type to be required. If you would like to save the existing blog post without providing a subtitle, the driver will pass the BlogPost.Subtitle as the Prefix and the name of the field.Text will be null. It's a small, but a good to know tip to provide a better user experience when editing values. Document Link Tag Helper There is a Tag Helper and a Liquid Helper in Orchard Core called Link that you can use to define the relationship between the current document and an external resource such as a favicon or stylesheet. This helper is available for a while, but there were no words in the documentation about it. Now you can find some lines in the documentation about how to use these helpers in your Orchard Core site. Add user updated event Two weeks ago we wrote about the new user deleted event, which is about to add a new DeletedAsync method to the IUserEventHandler. Now there is another new event for user events, that is about to occur when a user is updated. You can find the new UpdatedAsync method in the IUserEventHandler. And a new event is also accessible from your workflow type. If you create a new workflow type and click on the Add Event button, you will find the User Updated event in the User category. Password configuration documentation The password restrictions are set with the settings configured in ASP.NET Identity. Those options are used to define the required password strength when a user password is set. You can configure these requirements in order to specify properties like the minimal password length or if the process is expecting digits, uppercase, or non-alphanumeric characters. Check out the new how-to guide in the Orchard Core documentation to see how to change these settings and how to read configuration from an external config file! Demos Shortcodes improvements Two weeks ago we wrote about the upcoming Shortcodes feature for Orchard Core. Shortcodes are essential to WordPress, and for the Orchard Core, we wanted a similar feature. The parser was written by hand as the syntax is simple and it needs to be efficient. Check out that post if you haven't read that yet and don't forget to watch the recording on YouTube about that too! Now, let's continue from where we left off and see the newest improvements in that module! Set up your site using the Blog recipe, then head to Configuration -> Features to enable these features: Shortcode Templates: The Shortcode Templates feature provides a way to write custom shortcode templates from the admin. Shortcodes: The Shortcodes feature adds shortcode capabilities. Now head to Design and notice that the Shortcode Templates options is renamed to Shortcodes. Click here and add a new Shortcode! Here you will meet with a slightly changed editor. The first thing that you will notice is when you are starting to fill out the Name, the Hint, and the Usage inputs you will get a live preview in the right about how the card of the Shortcode will look like. You can ask what card do we mean, but let's not move so fast! The Categories selector is now working the same when you add tags to your blog post. You can type to search for the existing categories or add a new category right here from the editor. The Content will be about having the logic of the Shortcode. Here we create a Shortcode called safeimage, it means we sanitize the input from the user before rendering the content. We also created another Shortcode called unsafeimage. That would be the same, the only difference is we didn't call the sanitize Liquid helper. Now edit the Article content item named About. The HTML editor here has the Insert Shortcode button on the toolbar. Click on it and now you will see the cards we have just mentioned a few lines ago! Here you can filter by the name of the Shortcode and can filter by categories. Now let's try out the unsafeimage and the safeimage Shortcodes! After editing the code we have the following lines in the HTML body: unsafeimage: [unsafeimage]media/samoyed.jpg" onload=alert('xss')[/unsafeimage]unsafeimage: [unsafeimage]media/samoyed.jpg[/unsafeimage]safeimage: [safeimage]media/samoyed.jpg[/safeimage] Notice the script in the first line! Because we added this inside an unsafeimage Shortcode, it will render the alert when the user views this page. If we would put this little hack inside a safeimage Shortcode, then it would prevent the alert to appear. But that's not all about Shortcodes! If you would like to see more, don't forget to check out this recording on YouTube! News from the community RESTful web API sample in the Lombiq Training Demo for Orchard Core The Lombiq Training Demo for Orchard Core is a demo Orchard Core CMS module for training purposes guiding you to become an Orchard developer. You can use this module as part of a vanilla Orchard Core source that includes the full source code - which is the recommended way. You can also use it as part of a solution that uses Orchard Core NuGet packages, however, it's harder to look under the hood of Orchard Core features. And the module just got a new little RESTful web API sample! Check it out if you're learning Orchard and want to develop web APIs! Orchard Core workshops The contributors of Orchard Core will hold some unique online workshops in September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 157 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! There will be no This week in Orchard post next week because of vacation, so see you in two weeks!

Shortcodes, Audit Trail - This week in Orchard (31/07/2020)

This week we show you two demos of the brand new upcoming features of Orchard Core! The first one is the Shortcodes feature, that allows text content editors to inject specialized content blocks using custom arguments, like images, twitter embeds, youtube videos, only with simple blocks like [video 123]. The Audit Trail module provides log records for creation, deletion of any Content Type, and events like user events, as you may see it Orchard 1.x. Heads up for a post full of demos! Orchard Core updates Add user deleted event In the OrchardCore.Users.Handlers.IUserEventHandler there was no contract for the user deleted event. From now there is the new DeletedAsync method that is invoked if a user has been deleted. Check out the code in the UserStore.cs file, where you can see the invoking of the new method. This new event is also accessible from your workflow type. If you create a new workflow type and click on the Add Event button, you will find the User Deleted event in the User category. Admin CSS/Bootstrap regressions Back in Bootstrap 3, col-lg means nothing, so we had some special CSS in the admin theme to make it mean something. In Bootstrap 4, the col-* now means something, because here you have auto-sizing columns. It's still not exactly ideal because there is a lot of variation for the sizes. You can see the new names here to make them more meaningful. These are the new classes in the TheAdmin.scss file. Demos Shortcodes Sébastien Ros created a new open-source project called Shortcodes. This is a .NET library to parse and evaluate shortcodes. It allows text content editors to inject specialized content blocks using custom arguments, like images, twitter embeds, youtube videos, only with simple blocks like [video 123]. Shortcodes are essential to WordPress, and for the Orchard Core, we wanted a similar feature. The parser was written by hand as the syntax is simple and it needs to be efficient. Thanks to Dean Marcussen, this library will be integrated into Orchard Core soon. In this demo, we will see what we can do in Orchard Core using that library! Let's say you installed your site using the Blog recipe. Make sure that the Shortcodes feature is enabled. When you are editing a content item with a WYSIWYG HTML editor (for example the HtmlBody Part of the Article content type or a content type with a MarkdownBody Part) you can get a little pop-up if you are clicking on the Insert Shortcode button near the Link button by default. The pop-up will contain a list of the available shortcodes. Let's try the one called bold now. As you may guess, this shortcode is about to make your text bold. Select it from the list and provide the text that you would like to appear as bold. Note that here we used the [bold "bold text"] syntax when made the text bold. That works, because if you check the definition of the bold shortcode, you could see that we get the value of the text using the args.NamedOrDefault method. If we don't use the text named argument to pass the value of the content that we want to make bold, then it will just simply use the default one, meaning that it will use the content without any argument. So, if you are using the syntax [bold text="bold text"] you will get the same result. But the bold shortcode is also supporting content arguments. It means shortcodes using opening and closing tags can access their inner content. If you would like to use content arguments you can do something like [bold]bold text[/bold]. It will work because if the value of the text is null we will just use the value of the content variable that is the text between the opening and closing tags. Now let's see something else! If you navigate to Design in the admin UI, you will find a new option called Shortcode Templates! Let's see what a Shortcode Template is! Here you have the ability to actually write shortcodes in Liquid. Create a new one and call it Primary! This is about checking if your shortcode has something in the argument called text. If yes, we use the value of the text argument, if not, we are about to work with the content argument. The shortcode wraps the text in a span and adds the text-primary class to it. In this case, you can use this shortcode as you could see in the case of the shortcode called bold. But you also have the option to override the shortcodes that are implemented from code. In that case, you just need to call your shortcode template bold, and that will replace the existing one that has been written in code. If you would like to know more about shortcodes, don't forget to check out the demo on YouTube! Audit Trail Let's install your site using the Blog recipe. Then head to Configuration -> Features and enable the Audit Trail module. After you will see a new option in the menu of the admin UI called Audit Trail. The Audit Trail module provides log records for creation, deletion of any content type, and events like user events. So, let's do some content modification to see how you can use the Audit Trail feature! Navigate to New -> Article and publish a new Article content item with some data. Now edit some data in your newly created article and hit Publish again! Now navigate to the Audit Trail option on the menu and see the new records in the table. The audit trail table provides you with filtering and with pagination to be able to easily find the audit trail event that you are looking for. You can filter by a given date range, categories (All categories, Content Item, User), the user name of the user who caused the event to occur. Every record of the table can have a view in the Summary column. A record with the Content Item category shows you the version of the content item at the moment of recording. If you click on the Version X link you can see the read-only editor of the content item filled with the values that the content item has at that version. If you click on the display text of the content item you can edit the content item. Here you will see four recorded events regarding the changes that we have just made in the case of our article. The first one is about showing you the fact that we created the first version of the Article content type with the display text My new article. The second is about telling you that you clicked on the Publish button, that means you published that article. After you will see a Saved event. If you publish a new version of the article, Orchard Core first saves a new version of it (it also creates a new draft version), then publishes it. You can also see that now we have two different kinds of versions of this article. Now let's see what we have just changed in that article. To do that, click on the Details link of the Saved event. Here you can get more information about the given event. When you are checking the Detail view of a Content Item event you can see a table that contains the differences between the current version of the content item and the previous version of the content item in the Diff column. The values of the current content item will be shown in green, and the values of the previous content item will be shown here in red. You can show/hide this column using the Show diff switch. If you turn the Show before/after switch on, you will see two new columns: Before and After. These are about to show you the values of the properties of the previous version of the content item and the values of the properties of the current version of the content item. Here you can see we changed the Subtitle Text Field and the Html value of the HtmlBody Part of the article. If you navigate back to the audit trail table and check out the first Published event of the article content item, you will also see a new link here called Restore. If you click on this link, Orchard Core will create a new draft instance of the selected content item version. You can also restore the removed content items too. You can attach the AuditTrailPart content part to your content type that allows content editors to enter a comment to be saved into the audit trail event when saving a content item. This comment will be shown in the Comment column of the audit trail table. If you navigate to Configuration -> Settings -> Audit Trail you will find a list that contains every event that can you record using the Audit Trail module. Here you can enable or disable the recording of the given events. You can also enable client IP address logging. When you enable that, the client IP address will be recorded in audit trail event records. If you click on the Set blacklisted content types button you will see a new modal window with all of the defined content types in your system. Here you can select the content types that you don't want to log using the Audit Trail. For example, if you don't want to log the changes of the Article content items, then you may put a tick of the checkbox of the Article content type. The Trimming Settings is about to say how long you would like to keep the audit trail logs in the database. You can disable trimming if you would like to keep the records. And that's not the whole demo! If you are interested in the upcoming Audit Trail feature of Orchard Core, head to YouTube and check out the recording! News from the community A new website using Orchard Core Singapore is the third international country outside North America to introduce Starbucks to its discerning customers who readily embrace the Starbucks Experience. And they used Orchard Core to build the website for Starbucks Singapore! 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 Core workshops The contributors of Orchard Core will hold some unique online workshops in September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 154 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!

CodeMirror improvements, 100th This week in Orchard - This week in Orchard (26/06/2020)

The 100th This week in Orchard is here! In this post you could see a great demo about the CodeMirror improvements, we mention the updated Send Email activity, the new sample in our Orchard Core Training demo module about how to do unit testing, and many more! Thanks for joining us for the 100th time! Orchard Core updates Add Reply-To Header to Workflow EmailTask activity When you send an email to a subscriber and they click Reply, the reply message is typically sent to the email address listed in the From: header. A Reply-To address is identified by inserting the Reply-To header in your email. It is the email address that the reply message is sent when you want the reply to go to an email address that is different than the From: address. If you want to configure the Reply-To header in your EmailTask activity now you can do it! Just add the Send Email task to your workflow and use the updated editor of the activity! Allows ZoneShapes to be overridden If you were trying to override the ContentZone implementation in ZoneShapes.cs to get some different behavior for some tabbed shapes, it won't work, because it was not attributed with [Feature(Application.DefaultFeatureId)]. Just a note here: the [Application.DefaultFeatureId] attribute is used to allow core shapes to be overridden. Demos CodeMirror improvements CodeMirror in Orchard Core was a little bit outdated because it was not updated from quite a long time ago. All the views in Orchard Core have been changed that is using CodeMirror and now there is a new style called codemirror that is registered in the ResourceManifest.cs of the OrchardCore.Resources module. And that's not all, here you can see several other add-ons that are included by default. Here you can see the content of the TextField-CodeMirror.Edit.cshtml file. But let's see in action what can you do with these add-ons! When you are using HTML, you will have auto-close for the tags. If your text is too long, it will wrap the lines and the currently active line is being highlighted. And these features are provided by the newly added CodeMirror plugins. In this GIF you can see a Text Field and an HTML Field. We set the editor option to Code Mirror for the Text Field and Standard for the HTML Field. And as you could saw in the code above, you can turn on or off these features just by setting the values of the editor. If you don't want to have an auto-close tags feature, just simply say autoCloseTags: false. If you want to know more about the CodeMirror improvements, don't forget to check this recording on YouTube! News from the community Unit Testing in the Lombiq Training Demo for Orchard Core We added a new service and tests to it to learn a bit of unit testing! First, we'll create a service that we'll then later test in a test project. This service won't be used anywhere else, it's just an example to be tested. Why a service? Services are where usually most of the complex logic of an Orchard-based web app goes. You can test anything as long as you've written it in a testable way (by, for example, not utilizing hidden dependencies but injecting them all), you can write tests for controllers, drivers, background tasks, you name it. However, we think that unless you're aiming for 100% test coverage it's best to focus your unit and integration testing efforts on services. Then, the rest of the app can further automatically be tested via e.g. UI tests. Check out the service that will be tested here and here come the tests for it! This week in Orchard for the 100th time! We started our This week in Orchard series to inform our readers with the latest news and improvements around Orchard 1.x and Orchard Core. In this series we try to cover the most important features of the CMS and of course from time to time we are looking under the hood and show you the different code changes. But this series is not just for developers. We also want to target the super users of Orchard Core to know and be able to use every feature of it by learning the usage of the admin UI. Last year we started to upload Orchard Core demos in separate videos from the weekly podcasts to be able to find the given feature that you are really interested in as quickly as possible. We have also created a playlist for it on YouTube that contains more than 30 videos for now! And don't forget our Orchard Nuggets series that we have started in December last year! In that series, we answer common Orchard questions, be it about user-facing features or developer-level issues. Check out these posts for bite-sized Orchard tips and let us know if you'd have any questions! We hope that you like our series and find it useful! Thanks for reading us! 4000 stars on GitHub In GitHub, you can star repositories and topics to keep track of projects you find interesting and discover related content in your news feed. Starring a repository also shows appreciation to the repository maintainer for their work. Many of GitHub's repository rankings depend on the number of stars a repository has. And we are proud to present that on June 22, the Orchard Core repository reached 4000 stars and it's still growing! Congratulations on the community! Using the admin UI of Orchard Core - Orchard Core Workshop 3 Last Saturday we did a workshop with 11 attendees about how to use the admin UI of Orchard Core! This Saturday we are gonna show you how to develop a module. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 151 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!

Orchard Core RC 2 release, Visual Studio code snippets - This week in Orchard (20/06/2020)

We are thrilled to announce that Orchard Core RC 2 is now available! Check out this post to know everything about the latest release of Orchard Core. This week we will also show you a great demo about the brand new code snippets for Visual Studio, which will make your Orchard Core development more efficient! Orchard Core updates User menu as a shape There is a user menu at the top-right corner of the admin theme. In this menu, you could see the name of the logged-in user, and here is a button that you can use to log off. In the past, if you would like to change the look and feel of this menu, you had to override the whole Layout.cshtml file of the theme, because this was the file where we rendered the menu. From now there is a new shape called UserMenu, which is just about containing that piece of content that is responsible to display the user menu. So, if you would like to override that menu, just create a new Razor file in your admin theme called Usermenu.cshtml. Reviewing encoders usages There was a bug when you are sending an email, where your chars might be JSON-encoded. Let's say that you were using workflows to send a bunch of emails and in this case, Liquid is used to construct the body of the emails. You can have input data like "Country": "België" that you are rendering with {{order.UserProfile.Country}}<br />. However, workflow Liquid evaluator is using JavaScriptEncoder rather than HtmlEncoder. This results in an email with Belgi\u00EB in the body. By default when ASP.Net Core injects it's HTML helpers, it will encode all the Unicode chars. If you have any Unicode char, it will be encoded, which means you will not see the actual characters even if the browser supports Unicode characters. To prevent that you can configure the WebEncoderOptions in your web application to say that the TextEncoderSettings will accept all Unicode ranges. That means it will don't encode anything that is based on Unicode ranges. It will still encode HTML, but any char that is a Unicode char will still be returned as a Unicode char and not as an HTML entity or a URL entity or a JSON entity and so on. It's better to just opt-in for the ranges you want, but in this case, it's just a sample code to show you how you can do that. If you look at your source code when you use such chars, you will see you will have lots of HTML entities instead of the chars you wrote. Once you do that, it could be the actual chars. And also, when you are using an encoder, just resolve it in the constructor, because the encoders are registered in the DI using the mentioned arguments. If you don't want to use the arguments (TextEncoderSettings) for a custom piece of code, then don't resolve the encoder, use HtmlEncoder.Default. For more information, check out the documentation! Demos Orchard Core code snippets for Visual Studio Orchard Dojo Library is a portable package of coding and training guidelines, development utilities. These are also part of the best practices and guidelines we use at Lombiq. This library contains Visual Studio code snippets to quickly generate code in some common scenarios during the Orchard Core module and theme development. To effectively use this collection of VS snippets just point the Snippets Manager to where you cloned or downloaded this folder. To do this go under Tools → Code Snippets Manager → select the C# language → Add and Add the whole folder. For Razor snippets to also work select the HTML Language and do the same. Do note that Razor snippets will only be suggested when you hit Ctrl + space first. You can download the snippets from this GitHub repository. For example, if you type oc, the IntelliSense in Visual Studio will show you the suggestions. In the screen below you could see the code that is generated if you are using the ocmigrations snippet. That is about generating a class that implements the DataMigration abstract class and you will also get a Create method, that is the minimum requirement if you would like to add a migration. But that's not all! Check out this recording to see more snippets in action! News from the community Orchard Core RC 2 released We are thrilled to announce that Orchard Core RC 2 is now available! There is a new blog post in Orchard Core Blog that shows you the new features of the latest release. Here you could find the content localization support, and pre-configured localized Setup experience, the improved block content management experience, sitemaps management, and Azure support improvements. The NuGet packages are also updated on nuget.org. It's still prerelease of Orchard Core (the last one), so if you would like to update the packages in your solution, don't forget to put a tick in the Include prerelease checkbox if you are using Visual Studio. And don't forget the Roadmap! Here you could see a list of the fully or partially implemented features and the plans for the future releases! Upgrade your solution to RC 2 now! Feel free to drop on the dedicated Gitter chat and ask questions! Lombiq Utility Scripts Our Utility Scripts project is now open source! Many scripts for Orchard Core, Orchard CMS, Azure, SqlServer development. E.g. quick Orchard Core solution init, reset/reinstall. Head to the GitHub repository to see all the included scripts! Lombiq's Open-Source Orchard Core Extensions is now updated to RC 2 Looking for some useful Orchard Core extensions? Here's a bundle solution of all of Lombiq's open-source Orchard Core extensions (modules and themes). This repository contains the Helpful Libraries for Orchard Core that includes DateTime Libraries with TimeZone conversion, Localization Libraries and many more! But it also contains the Vue.js module for Orchard Core, the Training Demo module and that's not all of it! A new blog post about Orchard Core Nuno Cancelo is a software Engineer, eager to learn, and even more to share knowledge. Last week he published a great post about the basics of Orchard Core and he planned to publish 3 more parts where he will write about how you can create a module, a recipe, and a theme. Don't hesitate and start this journey now! Orchard Core workshops The contributors of Orchard Core will hold some unique online workshops in the coming months, between May and September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Lombiq's developers will also give two workshops, on using Orchard from the admin UI and on developing a module. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 148 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!

OpenAPI, Swagger, Taxonomy Localization - This week in Orchard (12/06/2020)

This week we prepared with two new demos: the Taxonomy Localization and the Orchard Core OpenAPI Code Generation Tools based on NSwag! But before doing that, let's see the latest changes that will be added to the RC2 release of Orchard Core that is now really just a few days ahead! Orchard Core updates Refactor Blog recipe to have fewer required fields You may found that creating blog posts in Orchard Core using the Blog recipe could be not very user friendly. When you create a new blog post, you have to provide tags and select the category for the posts, however, you will also need to add a banner image for it. These are all required fields, without these, you cannot publish your post. But from now these fields are optional and the Markdown editor is just below the Title and the Permalink, so you don't need to scroll down to start typing your new exciting post! Add ConfirmationEmailSubject to RegisterUserTask When you are dealing with workflows you can find a task called Register User. This is about register a user from a form field, meaning that the activity is getting the request body as a form to get an IFormCollection and try to get the UserName and Email values from that. If everything goes fine, the task will register the user and if you edit the activity, you will find some more stuff to set up! Here you can say to send a confirmation email to the user with a given subject and you can also use a template for the confirmation email if you want! How to contribute to the Orchard Core documentation? Have you ever thought about contributing to the Orchard Core documentation, but you cannot find a line about how to do that? Well, here comes the good news! From now, you will find a new guide in the documentation that tells you everything that you need to know to add your great getting started guides, tutorials, and everything to the documentation! Thank you for doing that! Change content API permissions You want anonymous users to be able to view your site, view your page/content item and it would just show what the layout is or the view is. But you might not want anonymous users to retrieve the full content item JSON payload, because it might shows some properties and metadata that you don't want to expose. For that, you could use the custom permission called GetApiContent that you can assign to specific roles and this is not assigned to anonymous users by default. Now, this permission was renamed to AccessContentApi and protects all /api/content methods. If you don't want a user to see all the fields, just don't grant access to the APIs at all, hence the GetApiContent permission is not required as a separate one. This will also protect POST that currently returns the full content. And one more thing: the GetApiContent was already added to the Authenticated role. Now it's removed from that role as being authenticated should not grant access to all fields. Prevent array duplication when merging existing content When you do Merge using JSON.Net it will just merge the different arrays. In some cases, it's not what you want. If you want an array to be replaced (for example an array of tags) then it will just add a new tag to that array and not replacing the array with a new array. On the POST operation of the API, you just want to replace the value and the PATCH operation should be the one that merges different arrays in this case. So, the Content ApiController needs to use ArrayHandling.Replace when updating existing content, or array values are duplicated. Here you can see the changed code and here comes the UpdateJsonMergeSettings: private static readonly JsonMergeSettings UpdateJsonMergeSettings = new JsonMergeSettings { MergeArrayHandling = MergeArrayHandling.Replace }; Demos Taxonomy Localization Have you ever wondered how to localize your taxonomy terms in Orchard Core? Well, it could be hard to do it for the first time, but if you are watching the following recording you can get some tips and tricks to reach your goal faster! Orchard Core OpenAPI Code Generation Tools based on NSwag Head to GitHub and clone the master branch of the ThisNetWorks.OrchardCore.OpenApi repository. Make sure that the ThisNetWorks.OrchardCore.OpenApi.Sample project is your starting project then just simply build and run the solution. When setting up your site don't forget to use the Open API Sample recipe to enable the needed modules and theme. If you navigate to https://localhost:44300/swagger, you will see the endpoints that are available in Orchard Core and a sample controller named Foo that comes from the ThisNetWorks.OrchardCore.OpenApi.SampleModule module. Here you can make queries on them and now we will also get schemas that are generated using the NSwag toolchain! Let's check for example the BlogPostItemDto! Now we can use those! The samples folder contains a console client that you can use to try the endpoints. You can simply open the solution with Visual Studio (ThisNetWorks.OrchardCore.OpenApi.ConsoleClient.sln) and fire up the ThisNetWorks.OrchardCore.OpenApi.ConsoleClient project. This is about calling the endpoints by using a static HttpClient. Open the Program.cs file and check the first few lines of the Main method here. You could see that we are getting a content item by the 4qnhdhv3z54xk4fg4tdfke76c9 and we get the content of the content item in the FooTextItemDto object. The content item with the mentioned ID is a content item of the Foo text content type, which has got one Text Field attached, named Foo Field. Our client modifies the text of this field and making a POST request to send the updated data to Orchard Core. Now if you read back from the API you will get the updated content item with the new text in the Foo Field. But there is a lot more than that! You can see that you can get the RecentBlogPosts Lucene query and use the response data, or do other Lucene queries (like give me all the blog posts) and so on. If you are interested in it, there is also a TypeScript client (tsClient.ts) which has the same kind of classes and can be used directly from TypeScript. Of course, before doing that, you have to do the authentication, get the token, and so on. For that, you have to enable the OpenID module and configure it. It also comes with the recipe by default. The back-end, the Swagger is using Authorization Code Flow, and the console client is using Client Credentials Flow. The client app has a specific API role because it's relevant to just give very limited and specific access to the system. And that's not all of it! If you need more details about the project, don't forget to check the recording on YouTube! News from the community Orchard Nuggets: How to access services from another tenant in Orchard Core? Do you run a multi-tenant Orchard Core site? Have you ever wondered how you can cross tenant boundaries? We show you the code! Check out our latest Orchard Nugget post for more! Check out the other posts for more such bite-sized Orchard tips and let us know if you'd have another question! Updated Dojo library We've updated the famous Dojo Library to Orchard Core! Orchard Dojo is a portable package of coding and training guidelines, development utilities. Check out our updated library and start learning today! Orchard Core workshops The contributors of Orchard Core will hold some unique online workshops in the coming months, between May and September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Lombiq's developers will also give two workshops, on using Orchard from the admin UI and on developing a module. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 146 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!

How can I call an external API from a workflow task? - Orchard Core Nuggets

You have several options to send an HTTP request to an external API in Orchard Core, but maybe you haven't tried the Http Request Task. Let's see quickly how you can hook up a workflow! The HTTP Request Task comes from the HTTP Workflows Activities feature, so before doing anything, don't forget the enable that module. Now navigate to the Workflows option from the menu and hit Create Workflow Type to add your workflow. JSONPlaceholder is a nice fake online REST API that you can use whenever you need some fake data. It comes with a set of 6 common resources and we are going to use the first one and making a GET HTTP request to get 100 user posts in a JSON format. Choose the Add Task button in the Workflow editor and select the HTTP Request one from the HTTP category. Here you can see a nice editor where you can provide the details of your request. We added a custom title to our activity as Get 100 posts. The URL will be the URL provided by the JSONPlaceholder API. To get the posts we have to make a GET request. If you would like to add a new post, make a POST request to the same endpoint, and provide the body to send. Don't forget to handle the 201 HTTP response code, because this will be the number that will show you that you are good to go and the server faked that your content was created. You may notice that you can type Liquid code everywhere in this editor. Let's say that the title of our new post will be the name of our site. To do that, we can pass the {{ Site.SiteName }} Liquid expression. As we mentioned, we get 201 if everything goes well. If the server returned with anything else, then something bad happened and we should handle that in our workflow of course. To handle the failed requests, we can use the Unhandled HTTP Status branch of the HTTP Request Task (we named in Create a new post) and notice the user somehow. OK, it's not a useful workflow, because we are only dealing with the response codes, but not with the response body. But how can we use the response details? To find the answer we have to check the source code of the HTTP Request Task activity and take a look at the ExecutyAsync method. Here you can see that the code uses the LastResult of the workflowContext and the LastResult has a Body property where you can find the response body itself. The LastResult property of the WorkflowExecutionContext is an object, that means you can easily put everything into the LastResult, but it could be a little bit harder to get the content from it. public override async Task<ActivityExecutionResult> ExecuteAsync(WorkflowExecutionContext workflowContext, ActivityContext activityContext) { using (var httpClient = new HttpClient()) { var headersText = await _expressionEvaluator.EvaluateAsync(Headers, workflowContext); var headers = ParseHeaders(headersText); foreach (var header in headers) { httpClient.DefaultRequestHeaders.TryAddWithoutValidation(header.Key, header.Value); } var httpMethod = HttpMethod; var url = await _expressionEvaluator.EvaluateAsync(Url, workflowContext); var request = new HttpRequestMessage(new HttpMethod(httpMethod), url); var postMethods = new[] { HttpMethods.Patch, HttpMethods.Post, HttpMethods.Put }; if (postMethods.Any(x => string.Equals(x, httpMethod, StringComparison.OrdinalIgnoreCase))) { var body = await _expressionEvaluator.EvaluateAsync(Body, workflowContext); var contentType = await _expressionEvaluator.EvaluateAsync(ContentType, workflowContext); request.Content = new StringContent(body, Encoding.UTF8, contentType); } var response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseContentRead); var responseCodes = ParseResponseCodes(HttpResponseCodes); var outcome = responseCodes.FirstOrDefault(x => x == (int)response.StatusCode); workflowContext.LastResult = new { Body = await response.Content.ReadAsStringAsync(), Headers = response.Headers.ToDictionary(x => x.Key), StatusCode = response.StatusCode, ReasonPhrase = response.ReasonPhrase, IsSuccessStatusCode = response.IsSuccessStatusCode }; return Outcomes(outcome != 0 ? outcome.ToString() : "UnhandledHttpStatus"); } } Imagine you are implementing a custom activity that creates content items based on the response body. For that, you need to get the JSON then serialize it to a typed class. That makes the data easier to work with. In the ExecutyAsync method of your custom activity you can get the JSON like: var responseBody = workflowContext.LastResult.GetType().GetProperty("Body").GetValue(workflowContext.LastResult).ToString(); Here the responseBody variable will contain a JSON in a string. You may notice that the value of the title here is Orchard Core, which comes from the {{ Site.SiteName }} Liquid value. To deserialize the response to typed classes you can use the built-in Json.NET package in Orchard Core and for instance, use the JsonConvert.DeserializeObject method of it. And that's it, now do what you want with the data. 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!

Click to deploy, Update Content Workflow Task - This week in Orchard (17/04/2020)

This week we come with a demo about an upcoming new feature of Orchard Core called Click to deploy. We also mention the improvements of the workflows and the documentation. Don't forget we published three new Orchard Nuggets post this week! And it's time to release Orchard Core RC 2! Orchard Core updates Tab placement documentation You have the option to place a part in a different tab in the editor of the given content type. To do that, you have to add a custom placement.json file to your module. In that file, you can tell the name of the part that will be moved to another tab and the name of the tab which will be created on the fly. Fixes Workflow Timer There was some issue with the Timer event that would reenter themselves. There is a new parameter called isExclusive: when we invoke a workflow task we can say this task should not be re-entered. If it's true, a new workflow instance is not created if an existing one is already halted on a starting activity related to this event. If you would like to run it and it's already running, don't start it again. It's also fixing some background tasks executed in every minute and runs longer than one minute. Here you can see the TriggerEventAsync method in the WorkflowManager class with the optional isExclusive boolean parameter. And here you could see the TimerBackgroundTask that is responsible to trigger workflow timer events. Here you could see the TriggerEventAsync method call with using the isExclusive parameter. Upgrade documentation to Material 5 Orchard Core documentation is using MkDocs, which is a static site generator that's geared towards building project documentation. You can find several open-source themes for MkDocs, Orchard Core documentation is using the theme called Material Design theme. Material 5 has been released and now Orchard Core documentation is also using the new version. Here you can see the highlights of this new version. You can also find a Samples page with great examples about how to use the different kinds of formattings which come from the extensions provided by the new theme. If you click on the pen icon at the right-top corner of the page you can see the Markdown syntax of this page. Adding Update Content Workflow Task When we create a new workflow, we had three different tasks related to content operations: Create Content Delete Content Retrieve Content Unpublish Content Publish Content From now we have a new task called Update Content. If you create a new workflow and hit the Add Task button, you will find this task in the Content category. Here you can set the content type and the content item ID to update and of course the JSON representation of the content item which will be used to update the content item. Demos Click to Deploy Click to Deploy is about adding a deploy action to the content item list. First of all head to Configuration -> Features and enable the Click to Deploy Content feature. Now go to the content items list by clicking Content -> Content Items. You have a dropdown called Actions for every content item. By clicking on this button you will see a new option, called Deploy. When you click that you will see the Available Targets window where you can choose any of the targets that you have preconfigured. If you choose the File Download option you will get a recipe that contains the particular content item in it. But you can use bulk actions too to deploy multiple content items as well. It's configured by creating a particular deployment plan and it's possible to add just the Click to Deploy Content deployment step to the plan or you can also choose to add a content definition step for example. So, in case of every time if you ship a new file to a remote server you will transfer the content definitions too. There is a little setting that you have to set under Configuration -> Import/Export -> Click to Deploy Content. Here you have to pick the particular plan that contains a Click to Deploy Content deployment plan. And the selected plan will be used when you are hitting the Deploy button in the content items list page. If you are interested in the full demo don't forget to watch the recording on YouTube! Note that this feature is under development and can be found in this branch! News from the community It's time to release Orchard Core RC 2! Orchard Core RC 1 was released on Sep 24, 2019, which was more than a half year from now. In the meantime Orchard Core has several new features and bug fixes, which makes it a more stable CMS, that is now used in several sites in production as well. Just remember the sites in Show Orchard with the Orchard Core category. Another issue is that the RC 1 release is using the .NET Core 3.0 version of the .NET Core framework, which is now at the end of support, that means that release has reached the end of life, meaning it is no longer supported and it is recommended to move to a supported release. If you navigate to the issues page in GitHub, filter for the rc2 milestone. Here you can see only the things that are required for RC 2. The real issue here is to update module manifest URL and version and to prevent custom scripts by default. After that, the community will ship the new release of Orchard Core! New Orchard Nuggets posts Let's imagine you've already created an Orchard Core app and now it's time to show it to the world. How do you publish it, or rather, how do you create its publish package? Build processes of .NET Core apps like Orchard Core are getting quite complex nowadays, and the MSBuild build pipeline also commonly includes steps for building client-side resources or doing a lot of things out of the .NET world. What can you do if something goes off course with all those targets and props files and you're just scratching your head? How to figure out what happens during the build if you can only see that the results are incorrect? In our newest Orchard Nuggets posts, we give you the answers! Read this Nugget for an answer about how to publish an Orchard Core app, the second one about how to debug an MSBuild build process when building Orchard Core and the third one for 4 ways to display something from your module nested within a page in Orchard Core! Don't forget to check out the other posts for more such bite-sized Orchard tips and let us know if you'd have another question! Orchard Core workshops The contributors of Orchard Core will hold some unique online workshops in the coming months, between May and September 2020. So even with Orchard Harvest postponed due to the coronavirus pandemic we'll get some new learning events. Lombiq's developers will also give two workshops, on using Orchard from the admin UI and on developing a module. Are you looking to get up to speed with Orchard? Check out the workshops' details on the Orchard Core homepage! Orchard Dojo Newsletter Now we have 136 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!

User disabled/enabled events, filter admin menu - This week in Orchard (07/02/2020)

Orchard Core has got several new features and fixes this week! With many others, we will see the new user disabled/enabled events, the new IAreaControllerRouteMapper implementation, the way how you can filter the admin menu then show you a demo about how to integrate stripe.js in your Orchard Core application with workflows. And finally, say some words about a new tentative date and location for the upcoming Harvest! Orchard Core updates Reduce the length of indexes for Content Fields Indexing Let's focus on the LinkFieldIndex and check these two columns: the Url and the BigUrl. The Url is the one that is trimmed and indexed, and the BigUrl is the original data that is not indexed. If you are using MySQL, the maximum length that this provider can support in an index under UTF8 collection is 768. Now we set the maximum length of the indexed columns is to not be longer than the supported length. Do not check "Include all content types" in deployment step by default When you create a content type deployment step, the default is to export all types. Now, this is unchecked by default. Adding User Disabled/Enabled Events The IUserCreatedEventHandler is changed to IUserEventHandler and there are two new events: DisabledAsync and EnabledAsync events. These two new events now triggered in the UserDisplayDriver that will trigger the two newly created workflow events to make it work in your workflows. Adding IAreaControllerRouteMapper Now there is an updated way how the admin prefix is applied by using custom convention and constraint that will ensure that the admin URLs start with the admin prefix. And also ensure that it is done correctly for the controllers that are named AdminController, not the ones that start with admin. Before every controller that starts with admin could be an admin controller, but now with this new convention, it has been decided that only controllers named AdminController can be an admin controller. For example, a controller named AdminItemController doesn't fall into this category, so it can't be an admin controller. A concrete implementation being AdminAreaControllerRouteMapper that uses AdminOptions to provide a default route pattern that is used in the OrchardCore.MVC startup. Just as a reminder, if you have admin controllers you have to name them AdminController or have the Admin attribute on that. This will ensure that the URL is strictly using the admin prefix (or whatever you set it), and the user has the admin permission and this will also apply the admin theme to the views from this controller. Filter admin menu Head to Configuration -> Settings -> Admin and put a tick near the Enable Admin Menu filter checkbox. Now you will have a new textbox at the top of the admin menu with a Filter placeholder text inside it. If you type something here you can filter the menu items and could find easier the option you want. And if you hit CTRL+SHIFT+F, this textbox will get the focus and you can type the menu option that you are looking for without needing to click into this textbox. Add menus content listing and create option If you navigate to the Content option of the admin menu you will find a new one, called Menus. This feature is listing all the menus of the system, and if you can see, there is a new button, called New Menu. By clicking on this button you can create a new Menu without needed the Menu content type to be creatable. Make lists sortable with ordering setting A few weeks ago we write about a way how you can make sortable lists using the Enable Ordering setting of the ListPart and you can also find a demo on YouTube about this feature. The good news is this feature is now merged to the dev branch of Orchard Core! Checkout to the latest changeset of the dev branch and try this feature now. Then don't forget to tell your opinion about it in the comments section! Razor Helpers documentation Now there is a new page in the Orchard Core documentation that contains the extension methods that are available in Razor using @Orchard. This documentation also contains the way how to use an extension method in a view and in a controller too. Demos Stripe.js and Workflows You can use Stripe.js’ APIs to tokenize customer information, collect sensitive card data using customizable Stripe Elements, and accept payments with browser payment APIs like Apple Pay and the Payment Request API. And of course, you can add Stripe.js to your Orchard Core site too! Let's create a registration form where users can register and after successful registration, they can pay the fee for a ticket. After the user submits the form, here comes a huge workflow, that will validate all the fields of the form. Here you can see the several validations, and when there is no error, the workflow will send an email, create an Enrollment in Orchard Core and redirect the user to stripe using a Fork. And there will be another workflow that will validate the payment using the response that Orchard Core will get from stripe.js. Now let's take a closer look at the Create Content Task that creates a new Enrollment content type. When you are creating a new content type using this task, you have to write the properties of the content. This is the JSON that is used to construct the given content item. As you can see, here you can use different Liquid expressions as well, for example, we could use the data coming from the form. You can see the website using this registration form under this URL. Here just click on the Register at the top right and select from the listed options. If you would like to see the whole demo just head to YouTube and watch the recording! News from the community A new tentative date and location for the next Harvest We have another tentative date for the next Harvest: the last week of June. In this date, we could do it in Europe and in a location that is easier to go from the USA too. London and Amsterdam have airports that can be reached easily from several other countries as well. What do you think about the new date and locations? Orchard Dojo Newsletter Now we have 114 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!

Cors, user account activation - This week in Orchard (31/01/2020)

This week we would like to show you two new Orchard Core demos: the user account activation and the new CORS module. But before that let's take a quick look at the newest features and improvements of Orchard Core! Finally, let's see what about the next Harvest? Orchard Core updates Add more Resources documentation The Resources page of the Orchard Core documentation has been improved a lot. Now on this page, you can find examples about how to register a named resource by implementing the IResourceManifestProvider interface, how to render your registered resources in the different sections of the page using Liquid or Razor and many more! Update the OpenID YesSql stores to execute a concurrency check on updates We have a new feature in YesSql when saving a session. Check out the following line: _session.Save(application, checkConcurrency: true); In the code snippet above, we would like to save the Open ID application and check that nothing has changed the application between it was loaded in this process and saved with the current changes. And if there is an issue, it will throw an exception when we call await _session.CommitAsync(). Then it will catch the ConcurrencyException saying something else changed the application while you were saving it so, please try it again. Fix issue with layers that can be drag and dropped to zones The targets for the zone dragging were too loose and then you could drag a widget to a layer or a layer to a widget. Now it's fixed. Fix regression for Tag Helpers not working There was an issue that some things were working in development mode and not in release mode. In development, Orchard Core finds the Tag Helpers because views are compiled at run time in the context of the application, while published .Views.dll files have been precompiled in the context of their related module or theme. In production, it will not work, because for example if you would like to use the ContentItemTagHelper, the reference was missing from one module to the OrchardCore.Contents module. Dean Marcussen created a new OrchardCore.Contents.TagHelpers project, that contains the Tag Helpers of the OrchardCore.Contents module. And now whenever we have Tag Helpers, we put them in their *.TagHelpers library. So, when our themes and other modules will need those Tag Helper, we can just reference this library and not the full module. In the _ViewImports.cshtml files where we are using the OrchardCore.Contents assembly to find Tag Helpers we need to look for the assembly named OrchardCore.Contents.TagHelpers. It should not break any websites if you are using Liquid, but if you are not using Liquid, it's possible that the site will be broke after this change, meaning the Tag Helpers won't be found and as we said, you need to change your _ViewImports.cshtml. In the future, we have to do the same for all of the Tag Helpers. Standard display option for each field If you want to add a Display option for a field that does not have a standard one, when you re-edit the settings and save, the new one will be selected as the default even if you don't want it. To solve this issue we added a Standard option for all the fields. Let's see the HtmlField.DisplayOption.cshtml file as an example. Sort Workflow instances Your Workflow could have several Workflow instances and if you have many of them, it could be hard to find the one you want. In the past, you had the option to filter the instances by their status (all, faulted, finished), and now there is a new option to sort these instances. You can sort them by the recently created or the least recently created. Simplify part settings retrieval for ContentPartDisplayDrivers In the ContentPartDisplayDrivers, we need to resolve the ContentDefinitionManager, query the type definition and then find the part that is named the same that we are using, take the first one and get the settings. But in the BuildPartEditorContext and UpdatePartEditorContext we already have the TypePartDefinition of the part that we are currently editing, so we can just get the settings from there. This change made the code simpler and technically faster. Just take a look at the changes in the AutoroutePartDisplay! Demos User Account Activation Currently, Orchard Core supports registration and approval or manual entry. What about having a way to have the option to invite users onto the platform and let them choose their password and then activate their account? Let's see a possible future release for this feature! Install your site and then enable the Users Registration feature. Now head to Security -> Settings -> Registration, where you will find a new option: Administrators can send an activation email to a user. Put a tick in this box and select the AllowRegistration from the select list. Now go to Security -> Users and hit the Add User button. Here you could see a new switch called Send Activation Email?. If you create this user with this switch enabled and hit Save, this user will get an email that email will contain an activation link. If the user clicks on this link, they can choose a password for the account. After they set the password their account is activated and they can log in to the site using the newly created password. To do that, you should disable the account of the user when creating it. But what's behind this feature? Create two new Workflows to send emails. Let's call the first one to UserAccountActivation and add the Account Activation event as the startup event for this Workflow. Then add a Send Email task that will send the email to the user. This email will contain the activation URL of the user. Create another Workflow that will send another email that tells the user that their account is activated. Let's call this Workflow UserAccountActivated. Here you could use the Account Activated event as the startup event and again, add a Send Email task. The feature will be improved in the future because as you can see, the Send Activation Email switch is not really about sending an email, it's just about rising an event, that you can use in your Workflows. Instead of this, we could have for example a user state (Needs Activation) similar to the IsDisabled switch. And that's not all! If you would like to know more about this feature, head to YouTube, where you can find the full demo about the user account activation! Cross-Origin Resource Sharing (CORS) module If you head to Configuration -> Features and enable the Cors Configuration module, you will find a new option under Configuration -> Settings, called Cors. If you navigate here you can add as many policies as you want using the Add a policy button. On this page, you can add the name of the policy, set that as the default policy and configure everything that you will need to enable CORS. If you are interested in the full demo, don't forget to check out the recording on YouTube! News from the community The possible date of the next Harvest We had two possible dates for the next Harvest: one in February and one in April. Now it looks like it won't happen in February, so the only option left is to do a Harvest in April. The possible days could be between 13 and 17 in April. We also have two possible locations, which are Nice and Miami. Stay tuned for more information about the next Harvest! Tell us about your .NET performance challenges! - Hastlayer developer survey Help us build the nerdiest .NET thing, Hastlayer: It turns performance-critical sections of .NET programs into computer chips! If you fill out our short questionnaire you can win a cool compute accelerator board worth $265! Check it out here: https://forms.office.com/Pages/ResponsePage.aspx?id=Wt6elek45kStyIVVO-uCIMkFNjqW2E1Pm4v3YMcflMNUOVlDNUE3MlpDS044VDI1OEFSMUgxUkxSTC4u The reason we're asking this is that we're building a .NET hardware accelerator, Hastlayer (https://github.com/Lombiq/Hastlayer-SDK it turns your program into a chip!) and want to better understand what other developers do. Thank you in advance! Orchard Dojo Newsletter Now we have 114 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!