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 >

GrahQL Queries queries, Negative role condition evaluator - This week in Orchard (07/06/2021)

We start this week by showing the ability to export templates as files, the negative role condition evaluator, and the brand new alternates for widget parts and for dynamic parts with great examples in the documentation. After, we will see a great demo about using templated GraphQL queries with Liquid. Check out our post for more! Orchard Core updates Add ability to export templates as files The idea here is in the exported ZIP file, the templates are now files instead of being embedded in the JSON recipe. Let's check it out quickly! Let's say you have the Templates module enabled (the Templates module provides a way to write custom shape templates from the admin) and have a defined template. If you set up your site using the Agency recipe, you will have one template, called Content__LandingPage, which is a template for the Landing Page content type, and the homepage of that installation is a Landing Page content item. Now, head to Configuration -> Import/Export and create a new Deployment Plan under the Deployment Plans option. Let's name the plan as Templates and add one Deployment Step to it, the All Templates one. Here you will see a new option: Export templates as files. Let's just put a tick in this checkbox to see what will happen. Now we have only one thing left to do, to execute the deployment plan. Let's just download the deployment plan locally and check the content of the Templates.zip file. Here you will see a Recipe.json file and a Templates folder. The Recipe.json file contains the Templates step with our only one Content__LandingPage template, and the content of that template can be found in the Content-LandingPage.liquid file in the Templates folder. Negative Role Condition Evaluator The way a role condition with a negative operator is evaluated right now doesn't take multiple roles into account. If we have 2 users: -- roleA roleB UserA X UserB X X The evaluator uses .Any() when evaluating the value against every role of the user. If we pick the operator "Equals" with the value "roleB", it will only be true for UserB, which has roleB. If we were now to just change the operator to "NotEquals" logically, it should be the opposite result of "Equals" but since the value gets compare against every role and roleA != roleB it will return true as well. .Any() (Current) Operator Value UserA UserB Equals roleB false true Not Equals roleB true true Contains roleB false true Not Contains roleB true true Using .All() with the negative operators which would give opposite results as intended. .All() Operator Value UserA UserB Equals roleB false true Not Equals roleB true false Contains roleB false true Not Contains roleB true false We have many negate operators, like StringNotContainsOperator, StringNotEndsWithOperator, StringNotStartsWithOperator, StringNotStartsWithOperator. Now, if you use them, the code execution will return with using the .All() instead of using the .Any(). If you don't know what are the rules and how to use them, check out the demo about the Rules module in this post! Validate content type and part names There was an unhandled exception during content item creation if you have a part named like property on ContentItem. The reason was that we have some reserved names that you cannot use when you are naming your content parts or content types. The _reservedNames HashSet here contains the names, that you cannot use. Use ZStringWriter ZString is a library that provides StringBuilder and StringWriter with zero allocation, meaning it's allocating an array on the stack for small buffers, instead of creating new StringBuilders and StringWriters every time. All ZString methods only allocate the final string. Also, ZString has enabled to access the inner buffer, so if the output target has stringless API, you can achieve completely zero allocation. Now we can use the new ZStringWriter instead of the existing StringWriter one. Alternates for Widget Parts This change contains several new alternates for widget parts and dynamic parts. And the documentation has also been updated with the new alternates. And when we are saying that the documentation has been updated, we mean that it's really got a huge update with many examples, like Display mode with Part Type and Shape without Display type Examples, Display mode with Part Type and Shape with Display type Examples, Display mode with Part Name and Custom Shape with Display type Examples and many more. Demos GraphQL Queries queries Let's meet with the new GraphQL Query type that basically allows you to use a GraphQL query in the admin interface and Liquid. It's using the same principle as the SQL query or the Lucene query. For example, let's say we have a GraphQL query created called ContactRequests, which is just about getting the Contact Request content items from the site. This query returns the contentItemID, the createdUtc, and the display text values of the Contact Request content items. But by using this experimental feature, you have the availability to use a templated GraphQL with Liquid. What do we mean? Well, first let's find the new Run GraphQL Query under Search -> Queries. Here let's add a template that contains Liquid code. By using Liquid, you can add output parameters to your query. In this case, we would like to get the email and the message fields too of the Content Request content items by using parameters. As you can see, we used the contactRequestEmail parameter to get the email and the contactRequestMessage parameter to get the message. If you open up the StatCan Orchard Core repository, you will find a collection of custom Orchard Core resources, modules, and themes that support various web applications and software-as-a-service (SaaS) products. One of the modules here is the VueForms module, which provides a form ContentType that simplifies using VueJs forms in the frontend. We had a demo about that one too, way back in 2020. If you don't remember about that, you can check out that in this post! And as always, if you want to know more about this feature, don't forget to check out the following recording on YouTube! News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 203 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!

Client-side validation of the form elements, fix content item shape usage in Liquid - This week in Orchard (26/05/2021)

Documentation updates, fixes for the content item shape when calling it using Liquid, a new extension method for the IContentManager, and a demo about client-side validation of the form elements. These are the main topics for our current blog post! Orchard Core updates Adding docs on the Recipes recipe step A recipe is a JSON file used to execute different import and configuration steps. You can add it in a Recipes folder with a name like this {RecipeName}.recipe.json, and it will be available in the Configuration > Recipes admin page. A recipe can execute multiple steps. In order to create a new Recipe step, you need to implement the IRecipeStepHandler interface and the ExecuteAsync method: public async Task ExecuteAsync(RecipeExecutionContext context). This page of the documentation mentions the available recipe steps, but the Recipes Step is missing from the list. Now you can read about what is the Recipes Step exactly and how you can add them to your recipe file! Fix content item shape usage in Liquid There was some confusion about the difference between alias and handle when using the content item shape in Liquid. The handle is the way you can reference content items with logical names and not physical IDs. In this case, you can reference a content item by its alias, which is the test here, or by its slug, which can be blogpost1. But if you type the alias here, it will still work because some code falls back to that. The Detail display type is the default one, so you don't have to specify it in the helper. But rendering the given display type here didn't work because there was an issue in the ShapeTag.cs code. As you can see, there was an argument.Name.ToPascalCaseDash() call for each argument. But the right method to use here is the ToPascalCaseUnderscore(), which takes display_type and converts it to DisplayType. Load items in Admin List Now you can find tons of new extension methods on the IContentManager to call LoadAsync. When you call this new ListAsync extension method, it will call the LoadAsync too, which will invoke the LoadingAsync and LoadedAsync events to acquire state or at least establish lazy loading callbacks. Don't allocate for page output writing in LiquidViewTemplate When we have the RazorPage class in ASP.NET Core, it has an Output property, which is about getting the TextWriter that the page is writing output to. We use that to render out our Liquid Templates. But when we do that, the output object is actually a buffered writer that will take whatever we write to it and buffer it and write it again to the actual results at some point. But what happens here is Liquid will write every snippet of data, every fragment to this writer, which will be duplicated in memory because it doesn't know that it can reuse it or who owns the data. Knowing that if we look at the implementation of ASP.NET, there is a class named ViewBufferTextWriter, that has a custom Write(IHtmlContent) implementation that would check if the object we pass is an HTML content. And if it's HTML content, then it won't try to allocate anything, it will just keep a reference to it. So, by doing page.Output.Write(content) it's now invoking ViewBufferTextWriter.Write(IHtmlContent) which doesn't allocate anything. And then, when the IHtmlContent is used, it should write directly to the response buffer. Demos Client-side validation of the form elements This demo is about form element validation. There is an in-progress pull request by Spike where you can find the complete form validation implementation using the Validator.js library, which is a library of string validators and sanitizers. We can use this to have validation for form elements with one rule both on the client-side and on the server-side in a user-configurable way. We set up our site using the Blog recipe and created a Page content item that contains a Form in its FlowPart and posts its input elements to a Workflow. The input elements are just about to demonstrate some validation rules. If you add a new Input, you can see some new fields, like the Validation Type, the Validation Options, and the Validation Message. As you will see from the Readme.md file of the Forms module, there is a high variety of functions that are implemented and can be used as the Validation Type. Now let's try out the Contains Validation Type! Let's say we have a rule that the textbox should contain the 'think' word. To do that, we simply write the 'think' word in the Validation Options textbox and also added a nice error message. But as you can see, there are lot more options that you can choose from to validate the inputs of your form, which works the same way. And here comes the workflow that we are using to submit the form. The FormRequest one is just a simple HTTP Request event followed by the Validate Form one, which checks whether the submitted form contains any validation errors. And if there were no validation errors, we redirect the user to the /Success URL, otherwise, the user will be navigated to the /Error URL. But that's not all of it! Head to YouTube now to check out the recording about this very useful upcoming feature! News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 199 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!

YesSql 3, Liquid Widget guide - This week in Orchard (17/05/2021)

YesSql 3 is here! Check out our current post to see what's new in YesSql, but first, read the new Liquid Widget guide and get to know why do the community needed to delete the Liquid Page and the Liquid Widget from the Blog and Agency recipes! Orchard Core updates Remove liquid type from recipes This is from a security report that if you have access to the admin, you can use and write in the LiquidPart. By using LiquidPart you can write HTML and JavaScript. It sounds obvious, but some sites don't expect users to be able to edit JavaScript on their pages, and it might have an issue. Because if you can write JavaScript, you can write XSS. The solution here is to remove the Liquid Page content type and Liquid Widget from the Blog and the Agency recipe. But the part is still there, and you can use it. And the Edit content types permission is marked as Security Critical. Meaning that, if you allow this permission to users, you let them be able to also use the LiquidPart and create some custom types that are about to render JavaScript in the frontend. Liquid widget guide As we mentioned previously, the Liquid Widgets from the default recipes were just removed. But that content type served as a very good example of how you can work with Liquid in Orchard Core. To have an example for working with Liquid, you will now find a new guide in the documentation about how to build a new Liquid Widget. Sometimes not having a feature but documenting how to use something is better than having a feature and no documentation about it. Did you know that our Helpful Extensions module for Orchard Core contains a Liquid Widget too, that adds Liquid code editing and rendering capabilities? Check out that repository for more goodies like the content definition code generation or the flows helpful extensions and many more! Use nameof for action name whenever it's possible Any controller action name that doesn't change can be called by using the nameof expression of C#. Now you won't break anything if you change the name of a method during some refactoring. Contents GetAsync: Recall published items Calls to IContentManager.GetAsync(string contentItemId, VersionOptions options) use IContentManagerSession.RecallPublishedItemId() to retrieve an already loaded content item if the request is to get a published item. The same could be used in GetAsync(IEnumerable<string> contentItemIds, bool latest = false) (i.e., the overload accepting multiple IDs). And the fix is here! When you do some loads with the content manager and if the content items are already have been loaded previously in the same request, there is no query that needs to be issued or just for the items that are missing. Demos YesSql 3 In the previous version of YesSql, every session created a new transaction automatically by default. Every session means even if your session is only doing reads. But when you are doing reads, you don't need a transaction because every read will be using the same transaction resolution. When you start a session in YesSql 3 and it's just about doing reads (like SELECTs) then it won't create a transaction. But the first time when you do a change on an object, the transaction will be created automatically (like when you would like to update a content item). Now it lazily creates a transaction if there are UPDATE, DELETE or INSERT statements. The second change is that if you really want to decide when the transaction should be created and not to wait for it to be automatically created. You can now call BeginTransaction and that will create a transaction or return the existing one if one is still open. And then there is another property (CurrentTransaction) that gives you either the existing transaction or NULL if there is no transaction. Everything has been renamed from CommitAsync to SaveChangesAsync. It's like in Entity Framework and now it's more obvious to know what it does (saves the changes). And what it means is that at that point if there is a transaction it will be committed and then released. If there is no transaction, it's just do nothing. And there is still the AutoFlush, meaning if you do some updates and then do a query to get some data, it will flush the changes from the database without committing a transaction, but your next request will be able to read the values that aren't in the database. Something that you can't do with YesSql before is let's say you start creating a session and there is an exception in the middle. If you didn't do a try-catch, and call CANCEL on the catch, it would commit the transaction because disposing of the session was committing the changes. In ASP.NET we don't have this issue because there is a rule that catches any exception that happens anywhere in the pipeline. But in some other apps, if you forget a try-catch, it would commit the changes even if it didn't go over the full list of commands that you want to execute. That was a big issue in YesSql. So, now that's actually changed. Meaning that if you don't call SaveChangesAsync now, it won't save anything. You have to call SaveChangesAsync at some point to commit the transaction. And if you disposing the session before calling SaveChangesAsync, it will cancel the transaction if it exists and closes the connection. So, SaveChangesAsync is now mandatory to mimic the EF behavior. So, if you have modules that use the session, you need now to call SaveChangesAsync, otherwise, nothing will be saved. But you should not have any module that calls SaveChangesAsync. And that's not all! If you would like to know every new feature and performance improvement included in YesSql 3, don't forget to check out the following recording on YouTube! News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 199 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!

Parlot, Make deployment steps orderable - This week in Orchard (07/03/2021)

This week you can meet with Parlot, which is a fast, lightweight, and simple to use .NET parser combinator! Check out our post for the orderable deployment steps, the improvements of the Kast platform, and many more! Orchard Core updates Make deployment steps orderable This is about making deployment steps orderable in the UI, to allow drag and drop to get steps where you want them to be. UI only, as the choice to when steps run should be up to the user. Let's say you have plenty of plans where features don't want to be first - more common when deploying to existing sites, rather than building up recipes, but steps are for both. And now you can also find hints to the important steps that suggest they should go first, like "Content Definitions should be placed before any content steps." Update from node-sass to dart-sass This is about replacing gulp-sass with its newer gulp-dart-sass because node-saas is now deprecated and the latest node-sass doesn't compile on the latest NodeJS anymore. So, it's recommended on the gulp-sass repository be upgraded to gulp-dart-sass as node-sass is deprecated. You can read more about it in this article. Fix WorkflowBlockingActivitiesIndex table indices name length for PostgreSQL This is an interesting one, so we think this should deserve a few lines. Check out the Migrations file in the OrchardCore.Workflows module where you can see the creation of two different indices: IDX_WorkflowBlockingActivitiesIndex_DocumentId_ActivityId and IDX_WorkflowBlockingActivitiesIndex_DocumentId_ActivityName. Because of the PostgreSQL name length limit, it uses only IDX_WorkflowBlockingActivitiesIndex_DocumentId_Activity for both which causes an exception. The fix is just to reduce the length of these indices. Add Properties to SetupContext There is a SetupContext class that had some properties like SiteName, AdminUserName, AdminUserId, etc. This SetupContext class will be prepopulated by the setup screen and then passed to ISetupHandler. But now the ISetupHandler accepts an IDictionary to work with these properties. But why is it useful? When setting up a tenant or site sometimes you need to pass in some custom data and use it in your setup recipes. Like when a user registers on a site and he submits a form with firstname, lastname, etc. We then call a workflow that creates the tenant and executes a setup recipe. In this setup recipe, we could create a landing page and we want to assign the firstname, lastname to be set as the displaytext of the landing page content item. Or another use case would be to populate the custom user profile settings during setup. So, from now, the developers can populate the Properties bag from his workflow task or a custom setup screen if they would like to. You can see a good example in the ExecuteAsync method of the SetupTenantTask. Demos Parlot The Shortcodes repository by Sébastien Ros contains a Shortcodes processor for .NET with a focus on performance and simplicity. And now that Shortcodes processor is updated to use a new parser called Parlot. Parlot is a French pronunciation of the word like chat or someone who talks a lot. In French, you write it parlotte. Parlot is a hand-written parser for Shortcodes and that parser is now extracted to make it reusable. You can find adding and using Parlot in the Shortcodes module in this PR. If you check out that pull request, you will see that before this PR we had the Character.cs, Cursor.cs classes. Now they aren't here anymore, they are in the package. The code is almost the same. Now we have a ShortcodesParser.cs that is using Parlot. And in this file, you can find the grammar of Shortcodes. A text is based on shortcode and TEXT nodes. A Shortcode can have an identifier and arguments. An argument is like identifier equals value. It's actually could be just a value if you want. And a value is either a string or a number. This class contains a bunch of first-level methods like ParseNode, ParseRawText, and so on. If you check out the JSON benchmarks of Parlot, you will see a nice table about the performance of Parlot. And in that table, you can see the performance of parsing JSON documents. As you can see, it is ten times faster than something like Sprache, which is a famous parser. Pidgin has been created to be faster than Sprache and now Parlot is faster than Pidgins. If you take a look at the allocations, you can see that they are equal because it's just about allocating JSON. This benchmark creates an expression tree (AST) representing mathematical expressions with operator precedence and grouping. Same thing here. This table is about comparing the low level, the fluent API, and Piding. Even the Fluent API is five times faster than Pidgin. And in terms of allocation, it's a little bit better than Pidgin. Here you can see a demo video about Parlot and a lot more than that! Like stories about the NCalc library that is created by Sébastien Ros 10 years ago. NCalc is a mathematical expressions evaluator in .NET. NCalc can parse any expression and evaluate the result, including static or dynamic parameters and custom functions. And that library is used by the Sprache.Calc library. Sprache.Calc provides easy to use extensible expression evaluator based on the LinqyCalculator sample. The evaluator supports arithmetic operations, custom functions, and parameters. It takes a string representation of an expression and converts it to a structured LINQ expression instance which can easily be compiled to an executable delegate. In contrast with interpreted expression evaluators such as NCalc, compiled expressions perform just as fast as native C# methods. We can fill up the whole This week in Orchard post just by these libraries and the story behind Parlot. Or we can start to describe how the parser works and how you can extend it with your own implementations, but this may no longer be closely related to the topic of this series. So, as we just mentioned before: if you are interested in these topics, this will be your presentation! Resource Zones, Resource Layers, Resource Widgets Kast is an Australian company and one of their primary goals is to implement the Kast platform with the Kast Group Finder component. We worked together with Seth Cleaver (Co-founder and Director of Kast) on this tool to be able to create an intuitive self-service process that enables people within a church to easily find a suitable group to attend, simplify the administrative processes required for getting people into groups, and provide information to the group co-ordinators that might assist in planning and measuring effectiveness. Check out this case study about how we've developed this multi-tenant social group management platform for churches! The Kast platform is growing from time to time and this time you could see an improvement from Dean Marcussen which is about providing ways to edit static resources (like JavaScript and CSS) using the admin UI. The exact issue in GitHub is opened by Dody Gunawinata a while ago about the downside of the current theme system is that to change anything will require deployment. The way around is to include the JS/CSS in a template and include them in every other template. Check out the following recording for a possible solution! It didn't seem like the design was wanted for Orchard Core itself, so it will probably remain private at this stage. But if the people wanted it, it might be possible to make it available at some point as a contribution module. News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 190 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post published to Orchard Dojo, including This week in Orchard of course. Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here! If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

New full_text Liquid Filter, Media Field improvements - This week in Orchard (14/11/2020)

See the improvements of the Media Field, the new full_text Liquid Filter, the enhancements of the admin UI, and many more in our upcoming post! Orchard Core updates ListContent Permission as Content Type dynamic permission Install your Orchard Core site with the Blog recipe and head to the admin UI. Navigate to the Security -> Roles and hit Edit near one of the roles. Type list in the search box that will list you some new permissions: the new ListContent permission on each Content Type. However, the global ListContent permission is of course priority over these. That means now you can decide which content items you want to list to the users in the given roles by using this dynamic permission. New full_text Liquid Filter Now there is a new Liquid filter called full_text. This lets you extract the full-text aspect of a content item. A full-text aspect being like metadata that we can get from any content item to represent it as full text. The goal being to be able to define custom full text for custom content types that will themselves use a full text of subitems. Let's say you have a Bag Part and you want to make your full text comprised of every full text of the items that you have in the Bag Part. To do that you can do a foreach on every item in the Bag Part and then you can call into their full text to provide it. Sticky bars on top while scrolling Last week we mentioned that the Features page has a new sticky bar on scrolling for very long pages instead of the scroll to top button. The good news is now more and more pages get this sticky bar on the admin UI. The Content Types page (Content -> Content Definition -> Content Types), the Content Parts page (Content -> Content Definition -> Content Parts), the Tenants page (Configuration -> Tenants), the Users page (Security -> Users), and the Recipes page (Configuration -> Recipes) are now also have a sticky bar. Fix double encoding of non-HTML strings in feed You can use the PopulateAsync method of the CommonFeedItemBuilder to build the RSS feed items using your content items. The RSS feed items have several properties like the link, guid, title, description, and so on. When we set the value of the title by calling the feedItem.Element.SetElementValue, the text that we pass will be encoded, so we don't need to encode it again, otherwise, we get it encoded twice. The same issue has been fixed in the ListFeedQuery feed query provider too. Initializing Liquid Include Filter There is an Include tag in Liquid that allows you to include an external Liquid file and in Fluid it's available through a FileProvider property, and in this case, the FileProvider property of the ILiquidFileProviderAccessor will be assigned to the LiquidTemplateContext. That means you can use it in your modules and your embedded assets. But how can you use that Include filter? Include your Liquid file using the {% include "Areas/TheBlogTheme/Views/Test" %} expression. This will include the Test.liquid file from the Views folder of the Blog theme. Demos New Media Field option to encrypt the image processing query string You could see a demo last week about the new options for Media Field where you can set the alt text of your image and you can also crop your images using a nice media crop picker. The way it was working is it's putting different kinds of options to the query string that allows you to manipulate your image. Let's see the following URL for an example: https://localhost:44300/media/post-bg.jpg?width=1&height=600&rmode=crop&rxy=0.2,0.5. Here you can see we set the width and height of the image from the media library. We also set the resize mode for the processed image with other parameters as well. Now there is a new bool option added to the MediaOptions called UseTokenizedQueryString to encrypt the image processing query string to prevent disc filling. That's true by default so you can try it out right away! To do that just simply open the predefined blog post and view the page source in your browser. Find the header HTML tag, where you can see how Orchard Core sets the URL of the background image. And that's not all of it! If you would like to know more about this feature, don't forget to check out this recording on YouTube! Orchard Core OpenID Connect Code Flow Api BlazorWASM We mentioned the Blazing Orchard project two weeks ago here in This week in Orchard that is a modular application framework that turns your Blazor project into a CMS-powered Blazor application by leveraging Orchard Core as a decoupled backend/CMS server using its REST & GraphQL APIs. In this demo, you will see a solution, that contains an updated version of Blazing Orchard that also contains OpenID Connect Authentication! Head to YouTube now to see the recording of this demo! News from the community Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 169 subscribers! We have started this newsletter to inform the community around Orchard with the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post published to Orchard Dojo, including This week in Orchard of course. Do you know of other Orchard enthusiasts who you think would like to read our weekly articles? Tell them to subscribe here! If you are interested in more news around Orchard and the details of the topics above, don't forget to check out the recording of this week's Orchard meeting!

Tabs, Cards, and Columns for the Admin, RenderTitle option - This week in Orchard (03/07/2020)

Heads up, several improvements coming this week! Editor shapes now support grouping placement, which allows you to group editor shapes, to create a variety of content editor layouts. The Title Part now has a Render Title option to show or hide the value of the Title. And last week we did an Orchard Core workshop about module development. Check out our current post for more! Orchard Core updates TitlePart with RenderTitle option and Placement for Form, Label Let's say you set up your site using the Blog recipe and want to edit the content definition of the Blog Post. If you edit the definition of the attached Title Part, you will find a new option that you can use called Render Title. With this option, you can enable or disable rendering the value of the Title Part in Detail and Summary display types. The Blog recipe using the TheBlogTheme by default where we override the content of the Blog Post (Content-BlogPost.liquid) and displaying the DisplayText of the content item whether the Render Title option is on or off. So, to see this in action we should use a theme where there is no override for the Blog Post content items. Let's navigate to Design -> Themes and make the Default Theme as the current for now. After that, you will be able to see the differences. The upper window here is about to render the title, but under that, you can see the default blog post without displaying the value of the title. We have some content types where is no need to display the title by default. These types are the Form and the Label. If you check the migration of the Label for example you will see how you can use the TitlePartSettings to hide the title by default. Fix jsonparse Liquid filter to supports arrays The jsonparse Liquid filter converts a JSON string to a JObject. This can be useful to build collections and iterate over the values in Liquid. Now, this filter is about to support arrays. To do that the community had to use the JToken.Parse method instead of the JObject.Parse one as you can see in the JsonParseFilter class. Add menu display text (differentiator) classes to menu shapes When using multiple menus on a site it is possible to do a lot of the styling with CSS, which can avoid having many, many templates. Now Orchard Core will add the menu differentiator (which is calculated from the display text) as an additional class on the menu. So out of the box, you will get: class="menu menu-main-menu". Demos Tabs, Cards, and Columns for the Admin We are able to use placement to move some of the fields/parts into a tab in the admin area. The new thing is now you can use Bootsrap Collape to organize your content into cards. And now you can also move fields into columns, in that case, you can have a Media Field near to the HTML Body Part for example. But after this intro let's go deeper and see some examples of placement. Modifier for tabs remains #, but now supports ; before as a position modifier for the tab grouping. Modifier for cards is %, also supports ; as a position modifier. Modifier for columns is |, supports ;, and _ as a column modifier, _9 will be applied as col-md-9 automatically, or _lg-9 which will be applied as col-lg-9. _9 should be sufficient for most, as it will by default break at md. ; must be immediately after , whereas : is the shape placement, and applies anywhere in the placement string. So, in nutshell the normal tab modifier is a #, the card modifier is a %, and the column modifier is a |. The column has a name and another modifier that allows you to say how big you want the column to be. Now try out these in your Orchard Core site! We will use the Orchard Core source to set up a site and we will modify the content of the placement.json file in the OrchardCore.Contents module. In the following example we place the MediaField_Edit shape in a tab called Media, and position the Media tab first, and the Content tab second. The Html Field goes first in the Content tab and the rest goes under the Html Field. Let's play with this a little bit more! Now we place the MediaField_Edit shape in a card called Media, and position the Media card first, and the Content card second. And lastly, we are playing a little bit with the columns. In the following example we place the MediaField_Edit shape in a column called Media, and position the Media column first, and the Content column second. We also specify that the Content column will take 9 columns, of the default 12 column grid. By default, the columns will break responsively at the md breakpoint, and a modifier will be parsed to col-md-9. If you want to change the breakpoint, you could also specify Content_lg-9, which is parsed to col-lg-9. If you want to know more check out the official documentation and don't forget to watch the video about the new features of the placement! News from the community Orchard Core RC 2 on ASP.NET Blog You can find a new blog post in the ASP.NET Blog that telling you the Orchard Core Release Candidate 2 now available! In this post you will learn how to create an Orchard CMS website using the templates, you will see the notable improvements and you can check out the development plan of Orchard Core! Module Development - Orchard Core Workshop 4 We had some great crowd at the Orchard Core module development workshop on Saturday, thanks all for coming! Would you like to attend a workshop too? Other community members will hold ones soon: https://orchardcore.net/workshops. Are you interested in something else? Leave a comment below! 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! There will be no This week in Orchard post next week because of vacation, so see you in two weeks!

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!

4 ways to display something from your module nested within a page in Orchard Core - Orchard Core Nuggets

A common question during Orchard Core development, something that came up again recently, is how to display something within the context of an Orchard page when that piece of data comes from your module? How can you "inject" something into the Orchard layout when you want to display e.g. a list of products retrieved from an external API? There are a couple of ways to do this depending on what exactly you need. All are fairly straightforward so let's see a quick rundown! Creating a whole page from you module If you want a whole page served by just your module then it's really simple: Create a module, add a controller as you'd do in standard ASP.NET Core MVC, make an action produce a view and that's it! The view will be wrapped into the Orchard layout so the theme you've selected will be visible around it: The basic styling will be there, the header and menu, any widgets you have put onto layers... Our Training Demo module has a simple sample exactly for this, just check it out and you'll see what we're talking about. The above screenshot comes from our Open-Source Orchard Core Extensions solution BTW. Creating a widget Widgets (see official docs) are basically little boxes of content or other functionality that you can put anywhere on the site. For example, an infobox about the site, a search box, a recent articles box, a footer can all be widgets. You can use them in two ways: Add a widget to a content item with Flow Part: Flow Part can be used to build flexible layouts out of various widgets, including nesting them (like putting widgets into a Container Widget). When you set up Orchard with the built-in Agency recipe and theme then you'll get a Page content type that has Flow Part out of the box: You can get the same content type from our Helpful Extensions Orchard Core module too. Another option to use widgets is to put them onto a layer, a sort of container of widgets. There you can place the widget into a global zone, an area of the Orchard layout, like the header, footer, or sidebars. The widgets on a layer will be displayed whenever the layer rule of that layer matches (you can think of it as a logic expression producing a boolean value), like on every page except the home page or on every page but only for authenticated visitors. For more info check out the docs. OK, but how can you create a widget? A widget is just a content item whose content type has its stereotype set as "Widget". You can change this value from the admin from under Content / Content Definitions and also from code. So, basically, the task is to create a content part of yours that'll display the data you want to show from its driver, then create a widget content type where that part is attached. Seems like a lot? It isn't, check out the relevant content part development tutorial again from the Training Demo, including creating a widget. Injecting a shape into the layout This can be a lot easier than developing a widget but also less flexible to use. You can also write your own code in a template (like a cshtml Razor file) and inject that into the Orchard layout directly. You can see an example of injecting a shape in the Training Demo module too. Displaying a shape from a Liquid Widget The Liquid Widget is a widget that can render a piece of Liquid markup. While there is such a widget in the Agency theme and you can throw it together from the admin quickly too the Helpful Libraries module has it built-in as well. With this widget and Orchard's pretty advanced Liquid support you can of course just write Liquid directly. However, for more complex apps maintaining templates editable from the admin quickly becomes an issue so we'd recommend keeping code in your modules and themes. The good news is that once you have a piece of Razor code in a cshtml template (or Liquid in a .liquid template) then you can just display it from a Liquid Widget! For example, if you have a WeatherData.cshtml template fetching some weather information from an external API then you can display it from a Liquid Widget, and thus use it just as any widget with this little piece of code: {% shape "WeatherData" %} There's more to it, check out the docs on the shape Liquid tag. Conclusion Pretty much that's it. There are other ways too but these are the most straightforward and most flexible ones. Do you have another technique you'd like others to know? Add below in the comments! 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!