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 >

Fix route ChangePasswordConfirmation, Fluid 2.2.14 - This week in Orchard (09/02/2022)

New custom path for the ChangePasswordConfirmation, Fluid 2.2.14 with several fixes and improvements, Orchard Core on the ASP.NET Community Standup are the topics of this week. Check out this post for the details! Orchard Core updates Fix route ChangePasswordConfirmation The idea is that now there is a custom route for the ChangePasswordConfirmation instead of using the generic one. So, the action OrchardCore.Users.Controllers.ChangePasswordConfirmation() is now mapped to /ChangePasswordConfirmation, because that action was mapped to /OrchardCore.Users/ChangePasswordConfirmation. And the documentation of Orchard Core has been also updated with this new custom path. Fluid 2.2.14 Fluid 2.2.14 has been released with several fixes and improvements. Let's see some of the changes here! The first one is about displaying the source of an error message. Now, if there is a parser error, it will tell you the location of the error (line and column) but it will also show the line with the error. And this way it's easier to understand where the issue is. And if you have multiple templates, for instance, then you don't have to guess what template contains the error because you can see the error directly. Now FluidParserOptions can be configured by using Fluid.MvcViewEngine. This introduces a small set of further changes to support the recent work allowing for FunctionValues. Update to FluidViewParser constructor to pass FluidParserOptions argument. Update to sample projects to use the new constructor. The next improvement is to fix some keyword conflicts. Someone finds an issue in Orchard is that if you have a variable that is named emptyThing, the parser would find that you mean the empty keyword and will fail saying what is this Thing after the empty? And it's the same for blank, true and false. So, if you have variable names starting with empty, you can have them now, this is what this PR is fixing. And another one is to implement offset continue. Now you can assign a range directly to a variable with this version. Before you could not. The second thing is that you can do offset with the keyword continue. So, in this case, continue is a keyword and what happens is that it will do another loop starting from where the previous loop stopped. So here, if you say limit: 2, it will start from the 4th item. And you can also pass another limit if you want. So, here the idea is that we loop for three items in the array, and then we loop again for the rest and display all the items. News from the community ASP.NET Community Standup - PO (portable object) localization with Orchard Core There was an ASP.NET Community Standup about localizing the .NET website. The topics were how the .NET websites have been localized using the Orchard Core localization package with PO files. Sébastien Ros did a demo about the package, explained how the localizer works, how to inject it, how to use the module, how to create a PO file, how to use pluralization, etc. If you would like to know more about localization, check out the recording of that standup meeting here! DotNest Core is on Orchard Core 1.2.2 DotNest Core is a complete redevelopment of the DotNest platform, all on the latest version of Orchard Core. We've been running it with a couple of select few customers for a while now, and it's time to open it up a bit more. While you can't yet simply create an Orchard Core-based DotNest site, you can sign up for our limited beta here. You'll soon be able to get a fully functional, reliably hosted Orchard Core site on DotNest where you can build your personal website or something to showcase your Orchard skills with. And now the DotNest Core sites run on Orchard Core 1.2.2! Do you want to have a hassle-free Orchard site running in the cloud? Then sign up for the beta here! Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 239 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!

Orchard Core 1.2.1 release, Remove exists check for blobs - This week in Orchard (20/01/2022)

Orchard Core 1.2.1 is now available to fix some security issues. Check out this post to know the content of this release of Orchard Core and to see the latest features of the framework! Orchard Core updates Remove exists check for blobs Instead of querying the blob, if it exists any time, we just try to get it, and maybe the server will return with a BlobNotFound error. This way, if it's there, we prevent one external network communication to check if it's there before asking for it. So, we just ask for it, and then if it fails, it fails. It's a pretty common issue with Blob Storage because of its high latency you need to do as few communications as you can. Starting background tasks without waiting for initialized tenants You can have a scenario where you would like Orchard itself to starts its background tasks without the need of a request for each one of the tenants. Until now, you need to make a request to as parent tenant and to every child tenant to be sure background tasks of each tenant start to run. So, by default background tasks are waiting for their shell to be lazily built on a first matching request. From now, you have a ShellWarmup bool option in the appsettings.json that allows you to eagerly build shells just before executing their first background task. News from the community Orchard Core 1.2.1 release Orchard Core 1.2.0 has been released on the 6th of January. But after a few days, a vulnerability security issue has been filed. That's the reason why the community had to create a new Orchard Core 1.2.1 release, to fix that security issue. You can update to the new version as usual. If you open up nuget.org and search for the OrchardCore.Application.Cms.Targets package, you will find the newest released version of Orchard Core! But let's see the fix that is in this release! It's not critical in the way that only users that are authenticated and have access to the dashboard can do things. Looking at the security issue and then how to not have them anymore. These are XSS issues, which means you can inject custom JavaScript in a page that could be triggered automatically, and then if you inject some fancy JavaScript you can force a user to submit queries and on this site, you could extract secrets or have them do things they don't want to do on the site. We encode everything we output. This means if the thing you output contains some JavaScript, it will be encoded, which means it will be rendered and not the JavaScript itself to be executed. In this case here, what was happening is that the translation was called on a variable, but we can't translate it. When we call T[], the IHtmlLocalizer will lookup for this text. If it finds this text in the translations, it will render the translation, otherwise, it will render the text as-is. That's why we always pass the English versions, such that if it doesn't find a localization, it will render this text in English. So, we don't have to create the translation for English, we just use that key that we passed. But the T[""] can contain HTML. And that's how we do to translate notifications, links, and stuff like this. And because it can contain HTML, the @ before that will just render it as is. So, whatever is passed there, it will be rendered as-is and not encoded. If we put some HTML or JavaScript inside that, this will be rendered as is and not encoded. What happened there is that when we do any string, like @T["Add widget"] is fine because we know this is a static string to generate. So, we know what we are rendering. But when we do it in a variable like @T[item.value], it can contain anything. And we don't know what it contains. And if it's user inputted, then there can be bad issues. So, we should never translate a user inputted value like this. This is an encoding issue over a bug. This is a list of SelectListItem, which itself contain a localized string instantiated value. There is no reason to use a localized string here. We use localized string as a type when we know that the property needs to be a localized string and should be a sign with a call to T for instance. This piece of code from the DashboardController is just to list the display name of the content type and the technical name of the content type. It's just a list of content types to allow you to create a new content item based on the type. The first solution is to don't translate variables. We have the design and started the PR for dynamic content translations, which is supposed to fix that, to provide a solution to be able to translate content types, permissions, and all the things that are user inputted and dynamic in the database (not static text). We should either not translate dynamic variables or use the new localization PR. The second option is to explicitly encode it for just this vulnerability. In this case, it's not breaking anyone, and it's secure because here, we explicitly translate the encoded value of the display name. So, it would break people who have spaces in their content type display name, because now they have to translate Foo content&nbps;type not Foo content type. .NET Foundation Most Active Community Projects 2021 Shaun Walker shared this image on Twitter that contains the most active community projects based on the number of pull requests, the number of commits, and the number of new contributors. As you can see, Orchard has 1507 pull requests in 2021, which is great. Orchard has 1291 commits, which is weird. Why do we have more pull requests than commits? Do we really close that many pull requests? We have some mini PRs created by Dependabot. And we haven't talked about which projects are using squash and merge and which projects aren't. But it's still a nice thing to be able to see Orchard in the top 10! :) Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 238 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!

Orchard Core 1.2 release, Background Jobs - This week in Orchard (14/01/2022)

We are thrilled to announce that Orchard Core 1.2 is now available! Check out this post to know the latest features of this release of Orchard Core and see a demo about an upcoming feature to have a jobs queue for scheduling! Let's get started! Orchard Core updates Support data annotations PO localization This feature is about to be able to localize data annotations. Let's say you have a required field and you would like to save your form without providing any value for that field. In this case, you will get a validation error of course something like: The {fieldname} field is required. And from now you can easily translate the default error messages for data annotations attributes. If you open up the DataAnnotationsDefaultErrorMessages sealed class, you will find the default error messages that you can translate. But how can you translate these? In your PO file, you have to target the DataAnnotationsDefaultErrorMessages marker class, provide the value of the variable that you want to translate (msgid), and provide the translated text after the msgstr keyword, which is the Arabic version in this case. In the following GIF, Hisham Bin Ateya shows you the given scenario mentioned above by using the Arabic translation for a required field. Code cleanup For C# code files, Visual Studio 2022 has a Code Cleanup button at the bottom of the editor (keyboard: Ctrl+K, Ctrl+E) to apply code styles from an EditorConfig file or the Code Style options page. If a .editorconfig file exists for the project, those are the settings that take precedence. After you've configured code cleanup, you can either click on the broom icon or press Ctrl+K, Ctrl+E to run code cleanup. You can also run code cleanup across your entire project or solution. Right-click on the project or solution name in Solution Explorer, select Analyze and Code Cleanup, and then select Run Code Cleanup. For more information about code style, check out this page. The codebase of Orchard Core got this cleanup, which means 312 file changes in this PR. And if you would like your code to be nicer, check out the Lombiq.NET Analyzers repository. Our Lombiq .NET Analyzers repository contains .NET code analyzers and code convention settings for Lombiq projects. We also had a demo about the analyzers in This week in Orchard post! Fix index cursors management When there are hundreds of thousands of rows the results returned by QueryIndex() may not be ordered by Id by default. In that case, services as AutorouteEntries using an index cursor on the Id column are not working properly, the _lastIndexId being not well managed. In this case when first publishing an item having an Autoroute, in place of only adding one Autoroute entry, it was trying to add thousands of them in an unordered way and was taking a very long time. Jean-Thierry Kéchichian also enhances the lookup of Autoroute entries to evict, the ones related to contained items of a given container. Demos Background Jobs Orchard Core has a background task infrastructure that runs tasks on a minute-by-minute schedule on a CRON job. But it doesn't actually allow us to have a queue where we can put jobs into a queue. This demo is about an upcoming feature to have a jobs queue for scheduling. In this demo (to show you this feature), Dean Marcussen used the Publish Later feature of Orchard Core to keep track of the background jobs, and by running a scheduler, you can run the Publish Later Job immediately without the need of waiting for the given time to be elapsed. Watch this recording on YouTube to know more about this upcoming feature! News from the community Orchard Core 1.2 release Orchard Core 1.2 is released! If you open up nuget.org and search for the OrchardCore.Application.Cms.Targets package, you will find the newest released version of Orchard Core! Upgrade your solution to 1.2 now! If you head to the repository of Orchard Core and head to releases, you will find the 1.2.0 release with the list of changes and the contributors. Feel free to drop on the dedicated Gitter chat or use the Discussions on GitHub and ask questions! Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 236 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!

Source Browser, Content Request Culture Provider cookie setting - This week in Orchard (12/07/2021)

Fixing forms multi submit, set the cookie in the Content Request Culture Provider, Source Browser with Orchard Core, and many more coming this week! Orchard Core updates Set the cookie in the ContentRequestCultureProvider The ContentRequestCultureProvider allows you to switch the current culture based on the content item URL. If you have a site in French and English and you go on a page that contains a French content item, then the full request will go in French. This is what the RequestCultureProvider does, it assigns the current thread culture to the one that a content item is taken. The issue is the following. Assume you have a drop-down French and English to switch languages. Like you are, for instance, on the home page for English. And in the drop-down, you select French using the content picker. In this case, your whole navigation is back in French. Everything you will click should be in French now; the widgets, the content items, everything. But if you go to a page that is in English, the cookie is still for French, which means the next page that will open will assume you still want to be in French. This new option lets you switch the cookie to the culture of the content item you are watching. That means if you go to a content item with a different culture, your cookie will say: 'Oh, I want to be in this culture now, I don't want to be in the one that the drop-down selected before!'. By default, the ContentCulturePicker sets a cookie for the CookieRequestCultureProvider. This can be disabled in the Configuration -> Settings -> Localization -> Content Culture Picker settings page. The ContentRequestCultureProvider can set the cookie based on the ContentItem that matches the current URL. This setting can be edited in the Configuration -> Settings -> Localization -> Content Request Culture Provider settings page. Minor security issue: Internal File Path Disclosure An issue has been raised that the Media module can potentially expose internal file paths, letting a would-be attacker find out what OS the server is using and gaining knowledge about the file structure being used by the web application. If you open up the AdminController and check out the HttpPost version of the Upload action, you would see the following lines in the code that prints the path of the given file. The media file stores are supposed to catch all exceptions and rethrow them as a FileStoreException. The issue was the result contains the path, while it shouldn't. This issue has been fixed by now. Fix forms multi submit The idea here is that if you add the no-multisubmit class, then you can't submit a form twice. So when you double click, there won't be two POST requests, just a single one. And the issues that it triggered were like locking issues or concurrency issues like two content items use the same version and then two published versions. This is preventing issues like this. And you had to change every single form to prevent that. Document Static File Provider Feature and robots.txt for Tenants There is a Static File Provider feature that allows you to have custom static files served for each tenant differently. And in this case, whatever file you put under the App_Data\Sites\[Tenant]\wwwroot will be served in priority over the module's static files or the theme's static files. This way you can customize, for instance, a CSS for a tenant by putting it in this folder. If all tenants use the same theme, you can customize CSS or JavaScript by putting the files there. If you would like to read more about this, check out this updated page of the documentation. Demos Source Browser Source browser website generator that powers https://referencesource.microsoft.com, http://sourceroslyn.io, https://source.dot.net, and others. Create and host your own static HTML website to browse your C#/VB/MSBuild/TypeScript source code. Note that it does require an ASP.NET Core website for hosting (symbol index is kept server-side), so without ASP.NET Core the search function doesn't work. Dean Marcussen decided to build one for Orchard Core. And you can now browse the source code of Orchard Core using Source Browser. You can find the source code in the dm/orchardcore branch of this repository. If you would like to see a nice demo and discussion about this feature, don't forget to check out the following recording on YouTube! News from the community Lombiq Helpful Libraries: Contents Libraries The Lombiq Helpful Libraries consist of several various libraries that can be handy when developing for Orchard Core CMS, to be used from your own Orchard modules. This time we will see some helpful constants and extensions regarding contents. The CommonContentDisplayTypes static class contains values that can be used with IContentItemDisplayManager.BuildDisplayAsync or OrchardRazorHelperExtensions.DisplayAsync to safely select the correct display type. Here we have a BuildDisplayAsync method that loads the content item if the display type is not SummaryAdmin. As you can see, we could use the SummaryAdmin constant string here. The PublicationStatus enum can be used for instance to query content items based on the status of the content item. The WithContentItem extension method also uses these enums to filters a query to match the publication status in ContentItemIndex. You can see we have a query.WithContentItem(PublicationStatus.Published) call that will extend the given query with the ContentItemIndex index and use the given status of the content item. Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 207 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!

Spatial Search, 5000+ Stargazers - This week in Orchard (02/05/2021)

This week you could see a demo about an upcoming Spatial Search feature for Orchard Core! Do you know that Orchard Core's repository now has more than 5000+ stargazers? Check out our post for more! Orchard Core updates Map Shape's public properties You could not do stuff like Shape.Classes, Shape.TagName, etc. in your Liquid templates. It was broken by the upgrade to Fluid 2.0. In Fluid, Shape, and ZoneHoldings uses ShapeAccessor which didn't map all properties (ie: Id, TagName, HasItems, Attributes, and Classes). Now it's fixed. Workflow CommitTransaction in a separate Workflow Feature Head to the admin UI of Orchard Core then navigate to Configuration -> Features. If you type the Workflows word in the search bar, you will get all the features that are related to Workflows. Now you will find a new one here called Session Workflows Activities. But there isn't anything new here really, it's just about having the Commit Transaction task in a new feature, because for some security reasons and usually, we don't need to use it quite often. If you miss that activity, now you will know where you can find it. :) Fix notification locale when the site is restarted There could be scenarios where there are multiple notifications in the same controller. But if we are restarting the shell meanwhile in the controller, we could face some issues. This fixes an old localization bug, especially when the default culture is set, some of the notifications are localized with the culture before the new culture is taking a place. Demos Spatial Search Let's set up a site using the Blog recipe. Now go to the admin UI of Orchard Core and first, enable the feature called Spatial. This feature provides the ability to add spatial locations to content items. Let's try that out now! For the sake of demonstration, we will create a new content type called Venue. Let's say that our goal, for now, is to be able to query nearby venues. The Venue content type will have a Title Part and an Html Body Part. But that doesn't really matter right now. Apart from that, we will add a new field to our content type, which will be a Geo Point Field. The Geo Point field can have a Leaflet editor type. Let's keep the other content type settings as default. Now let's see what kind of editor we will have if we open up the editor of our content type. As you can see, you can use a nice editor for the Geo Point Field to set up the Latitude and Latitude coordinates. This means you can simply enter them in the text boxes with these labels or you can just click on the map which will place a marker there with the given coordinates. Of course, you can zoom in and out using the plus or minus icons on the top-left of the map or just by simply scrolling. When you persist this content item, the position will be indexed in Lucene. Lucene now has some spatial search features which this PR implements. Now let's navigate to Search -> Queries -> All queries and add a new query. Select Lucene from the available query types. In the following example, we have just created a query that returns Venue content items based on a given location. You can see a geo_bounding_box filter here, which is about to return Venues where the location is within the boundaries of the given box. You can set the top, left, bottom, and right parameters of the box by using a JSON object. And that object contains parameter values for this query, which will be the parameters of the box in this case. But we are just scratching the surface of the upcoming Spatial Search feature of Orchard Core here. If you would like to know more, check out this recording on YouTube! News from the community Orchard Core repository: 5000+ stargazers and almost 200 contributors If you have visited the Orchard Core repository nowadays, you may notice that Orchard Core has almost gained 200 contributors! Right now the project has 197 contributors! Users on the GitHub website are able to "star" other people's repositories, thereby saving them in their list of Starred Repos. Some people use "stars" to indicate that they like a project, other people use them as bookmarks so they can follow what's going on with the repo later. And if you check out the number of Stargazers you will see that Orchard Core now has more than 5000 stargazers! Decoupled CMS Orchard Core tutorial for the Dojo Course After a long wait, last December we released the new Orchard Core version of our legendary Dojo Course tutorial series, the Dojo Course 3! Are you a newcomer and want to learn Orchard Core from the ground up, both from a user's and a developer's perspective? Are you somewhat familiar with Orchard Core but would like to get up to speed and become an Orchard pro? Look no further, check out Dojo Course 3! Dojo Course 3 guides you from the very basics of Orchard Core all up to be able to write your own themes and modules, utilizing various APIs of Orchard. Here you can check out the Dojo Course 3 YouTube playlist. All the video tutorials are here, in the recommended viewing order. Note that the video descriptions contain links if any were mentioned in the video. And now we are thinking about making a decoupled CMS Orchard Core tutorial for the Dojo Course to extend it a little bit. Orchard for the admin and content store, Razor Pages for the frontend. What do you think about this one? Are you interested? If yes, please tell us your opinion under this Tweet to be able to create that kind of tutorial in the future that you would love to see! Consultant needed for scalable TeamCity+Azure setup Do you have a lot of experience in configuring and operating TeamCity, hosting apps in Azure, and building a scalable Continous Integration environment? We're looking for you! Check the details here! Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 197 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!

User Picker Field, the new user ID - This week in Orchard (06/12/2020)

This time we will do a little deep dive and check out some important changes in the code base of Orchard Core. But don't be scared, we promise you will like these changes, especially the demo about the new User Picker Field! Orchard Core updates Allow media width and height values without a token You could see a demo a few weeks ago in this post 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. A few days later the community introduced a new bool option added to the MediaOptions called UseTokenizedQueryString to encrypt the image processing query string to prevent disc filling, that is true by default. And now here comes another great stuff that allows values for width and height to be provided via the query string even when tokens are enabled. What does it mean? Let's see an example of it! Set up your site using the Blog recipe then open the default banner image URL of the predefined blog post with the following query string parameters: https://localhost:44300/media/post-bg.jpg?width=1024&height=600. Note that the tokens are enabled by default, but you can still set the width and the height of the image now. Don't forget that this will only work if the height and width values match the supported sizes array values. Introduce Culture Scope There is a new CultureScope class that you can use if you want to locally set the current culture (the current user interface culture and the culture used by the current thread). You can find several unit tests to see how you can use it, but check out this one for now. Here you can see that the culture is set to French, but that setting only applies inside the using statement. Implement UserId All the user profiles that you have locally, now have a new property called UserId, which is unique. We used to use a name, the user name as the way to identify a user. But now the community decided to use a unique ID such that you can't guess user ID or you can't recover another set or permission or ownership by mistake, because an account has been deleted and someone created a new account using the old name and somehow the logical references are still kept based on this name and you would inherit something from that. So, to prevent that, Orchard Core is using now a user ID. If you take the latest version of the dev branch and just run your code there will be a migration that copies the user names of the existing users as the user ID. This way you don't have any change in your content, it will still work the same and be careful that your user ID equals a string like 4gq8jagmrtxrwvg21csa0b6y4y, which is safe, because the next time someone creates a new user, they can't impersonate anyone else like recovering an old account, because it will be a newly generated unique identifier that can't match something like that. And how can you find the currently logged in user? Check out the code in the DefaultContentsAdminListFilter where you can see that now, instead of using the user.Identity.Name, you can use the FindFirstValue extension method from ASP.NET Core to return the value of the first instance of the specified claim type, or null if the claim is not present. And then you can set that value as the Owner of the content item. Demos User Picker Field Let's say you would like to create a blog where multiple users can create blog posts and you want to connect the user account of the author user with the given blog post by showing the name of the user somewhere in the detail view of the post. It's easy because the users can log in to the admin UI of Orchard Core and publish their own posts. In this case, they will be the authors of the given content items. But let's say we don't want to give them access to the site. We just want them to send the content of the blog post to a given email address and the site editors will edit and publish the posts. Is there an easy way to connect content with user accounts in Orchard Core? Set up your site using the Blog recipe. This recipe comes with a predefined blog where you can create new blog posts. The posts can have several properties: the title, the banner image, tags, the category, and so on. We will modify the content definition of the Blog Post to do some tricks. Navigate to the admin UI of Orchard Core and head to Content -> Content Definition -> Content Types and edit the Blog Post one. Click on the Add Field button and find the recently added one, called User Picker Field. This field allows you to connect users with a content item. Here you can say that you want to allow multiple users to be selected, allow the picker to display users from all roles, and many more. If you put a tick on the Display All Users checkbox, every user will be in the list that you can choose from, if you remove the tick, the available roles in the system will be listed and you can choose from them. Now if you edit the predefined blog post, you will see the User Picker Field in action. In this case, we have two users in the system named admin and editor. The admin is the superuser with the Administrator role and the editor user has the Editor role. We can see both of them because we said we would like to allow the picker to display users from all roles. If you save your content item, the field will show you the user names of the selected users seperated by a comma (if you selected multiple ones). And you will see a No users. message is you haven't selected any users. You can find some lines about the User Picker Field in the documentation of Orchard Core and a nice presentation of this feature on YouTube! News from the community Our full Orchard Core tutorial series, the Dojo Course 3 is here! After a long wait, the new Orchard Core version of our legendary Dojo Course tutorial series is here, the Dojo Course 3! Are you a newcomer and want to learn Orchard Core from the ground up, both from a user's and a developer's perspective? Are you somewhat familiar with Orchard Core but would like to get up to speed and become an Orchard pro? Look no further, check out Dojo Course 3! Dojo Course 3 guides you from the very basics of Orchard Core all up to be able to write your own themes and modules, utilizing various APIs of Orchard. We're publishing a tutorial video every day for 40 days starting on 1 December. So, this is your 40 days of Orchard :). In the first few videos, we gave you an introduction to Orchard Core and showed you a way about how to set up your first Orchard Core website. After we started to talk about the content model of Orchard Core, checking out the basics of content management. We will stay in the admin UI for a little in the upcoming days and check out the other basic features of the CMS like how to add widgets with layers, managing the menus, and the media files. After we will see how can you search and index content items, and build forms using the Forms and Workflows feature. But we will not spoil the topics of the upcoming videos. :) If you're looking for our previous Orchard 1.x tutorial series check out Dojo Course 2. Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 172 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!

How to add a culture URL segment for localization in Orchard Core - Orchard Core Nuggets

So you're building a localized Orchard Core site and want all URLs to be in the form of /culture-name/rest/of/the/url, e.g. /hu-HU/my-page. (Figure out what "hu-HU" is! Hint: It's not an owl, neither a rock band from Mongolia!) What do you need to achieve this? Well, we've already seen how to localize content items to achieve this, but that's just for content pages. There is one small piece missing though: How to get the same functionality for controller actions, i.e. coded pages? There is nothing built into Orchard Core for this, actually. And the reason is that all you need is available in ASP.NET Core MVC already. First, you'll need to set up RouteDataRequestCultureProvider so the URL segment indicating the culture will be used to set the culture of the current request. Just add this to your module's or theme's Startup class (if you don't yet know how to build a module, check out our Training Demo!): services.Configure So far so good. Next, you'll need the controller actions you want to be culture-aware to be routed in a way that the culture name is included in the URL: public class CultureAwareController : Controller { [Route("{culture}/culture-aware"] public ActionResult CultureAwareAction() { // Build the result here. } } So now you'll be able to reach this action from under /hu-HU/culture-aware for example. There's one final part missing: Building URLs for these actions. This is quite simple too, you'd e.g. create a link for this action like following: <a asp-action="CultureAwareAction" asp-controller="CultureAware" asp-area="CultureAwareModule" asp-all-route-data="routeParams">Click here</a> That's it! Of course, this can get more complex. You can make route configuration as well as URL generation easier by centralizing this culture parameter handling, which is useful if you have loads of such controllers and links. 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!

Culture picker on the Setup page, CodeMirror editor for TextField - This week in Orchard (28/03/2020)

This week you could see a demo about the brand new culture picker on the Setup page! We will also check the new CodeMirror editor for the TextField, the new EmailAddressValidator service, a new Orchard Nuggets blog post and Lombiq's Open-Source Orchard Core Extensions! And that's not all! Orchard Core updates CodeMirror editor for TextField There is a new editor for the TextField, where you can use CodeMirror. To try this just install your site using the Blog recipe and edit the content definition of the BlogPost content type. Set the editor type of the Subtitle TextField to Code Mirror, then hit Save. And now if you edit the predefined blog post or create a new one, you will see the changed editor for the Subtitle TextField. It uses a text area, and of course, supports to write code here by different kinds of highlighting. Add DataAnnotation default error messages There is an issue filed that the DataAnnotation attributes are not localized correctly, because the actual strings to be localized are taken from resources or hard-coded in the DataAnnotation classes. In these cases, we don't have them in the PO files, so they can't be translated because the PO extractor doesn't find them. To solve that there is a new DataAnnotationsDefaultErrorMessages class, that defines all the strings that are currently in the resx files of ASP.NET, but as a custom class with calls to the StringLocalizer. This way the PO file extractor can find them and we can localize them in Crowdin and provide the missing PO files for that. The second step is actually to use them and ensure it works, but also be able to extract custom messages that you would put in the DataAnnotation. In a DataAnnotation like EmailOrRequired you might say Email but provide a custom string. In this case, in the custom string, we still need to extract it. At least the default messages that are nowhere in the code should be registered somewhere like this. So, we can have a reference list of things to translate and then the localizer will be able to pick the correct translation. That's a good first step. Prevent anonymous users from performing GET on content item API 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 show some properties and metadata that you don't want to expose. Now there is custom permission that is called GetApiContent that you can assign to specific roles and this is not assigned to anonymous users by default. Update Documentation for non-Visual Studio users Getting started with an Orchard Core Theme page of the Orchard Core Documentation has been updated with guides about how to create a new theme if you are using other IDE then Visual Studio. Add EmailAddressValidator service This one is to make a new IEmailAddressValidator service that is available by default in Orchard.Infrastructure.Abstractions. It's using MailKit so that's a new service that you can use to validate email. And if you would like to replace it, you can add your own logic for email validation. Add tenant description Now you can define a description of the views for each tenant. If you add a new tenant by navigating to Configuration -> Tenants -> Add Tenant, see the list of tenants or use the Create Tenant Task in your workflows, you will meet with this new option. Demos Culture picker on the Setup page When you have the latest dev you have this Setup screen where the new thing is the culture picker at the top right. Note that the Change language string not has been localized yet, so the default behavior is that it will show up using whatever language has been selected, the default one comes from the browser. Or if there is no match from your system, the default will be English. That won't configure the site for the same language because it's just the setup experience, so it won't enable localization by default. Because we have a quite much language translated and supported, the UI will adapt automatically to the selected one. If you take a language that would be an RTL language like Arabic, the direction of the text will also change. If you are interested in the full demo, don't hesitate to go to YouTube and view the recording! News from the community Orchard Nuggets: How to localize content items? So you want to create an Orchard Core website that presents its content in multiple languages. There are many parts of this, but what about content items? How do you make them ready for localization? In our newest Orchard Nuggets post, we give you the answers! Check out the other posts for more such bite-sized Orchard tips and let us know if you'd have another question! Lombiq's Open-Source Orchard Core Extensions An Orchard Core CMS Visual Studio solution that contains most of Lombiq's open-source Orchard modules and themes. Only those extensions are included which use the latest released version of Orchard (i.e. ones depending on a nightly build are not yet here). Since the extensions are included as git submodules when cloning this repo set git to initialize submodules Bug reports, feature requests, comments, questions, and code contributions are warmly welcome, please do so via GitHub issues and pull requests. Please adhere to our open-source guidelines while doing so. Orchard Dojo Newsletter Now we have 129 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 to localize content items? - Orchard Core Nuggets

So you want to create an Orchard Core website that presents its content in multiple languages. There are many parts of this, but what about content items? How do you make them ready for localization? We'll assume that you have your site already set up. We'll use the Page content type found in e.g. the Agency setup recipe as an example. First, make sure that you've set up available site cultures on the Orchard dashboard. This is under Configuration, Settings, Cultures (or the /Admin/Settings/localization URL). Set up LocalizationPart for content types to be localized as mentioned in the docs. Now comes the hard part: You need content items' URLs to be generated with the culture in it, so something like "en-US/demo". This is so you can have two versions of a content item, in different languages but with the same slug ("demo"). So, edit the settings of the Autoroute part from under the content type's editor under the Content menu on the admin, Content Definition, Content Types. For the Page type it's here: /Admin/ContentTypes/Page/ContentParts/AutoroutePart/Edit. There you need to change the default Autoroute pattern to include the culture's ID. This you can do by accessing the culture set in LocalizationPart, so the whole pattern will be something like this: {{ Model.ContentItem.Content.LocalizationPart.Culture }}/{{ Model.ContentItem | display_text | slugify }}. That's pretty much it. Now when you create a new Page you'll be able to tell Orchard which culture it belongs to and the URL will automatically reflect that. This is of course not the complete localization story. You'll also need to display the culture options to the user which you can do with the ContentCulturePicker shape as explained here. Other UI labels coming from code need to be localized too with PO files, as you can read about in the docs too. Have fun with your multi-language sites! We also have a follow-up post on how to add a culture URL segment for non-content pages. 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!

Scoped Liquid TemplateContext, Template Azure Blob with Liquid - This week in Orchard (10/01/2020)

Updated Trumbowyg plugin, configure your Azure Blob and Data Protection with Liquid and many more improvements are waiting for you in our upcoming post. Did we forget to mention that Orchard Core is now on the Area 51 site of Stack Exchange? Orchard Core updates Upgrade to ASP.NET 3.1.0 Orchard Core now using the v3.1.0 of the ASP.NET Core framework. This version is included in Visual Studio 16.4.0, so if you are using at least this version, you can build your own solution using Orchard Core. Here you can read a great article about the new features of this release. Validate Site Settings BaseUrl property You can set up the BaseUrl of your site under the Configuration -> Settings -> General on the dashboard. If you enter a URL, which is a not fully qualified URL, you will get a validation error. So, here you need to enter an absolute URL. Template Azure Blob and Data Protection blob configuration with Liquid You can customize the base path of the Blob Storage for media, for data protection and also for the container that you want to use. These can use a template in Liquid. If you have some custom rules to name your container or the base path, then you can define it this way. You can have access to the ShellSettings and the ContainerName properties. This will give you all the flexibility you need for instance to use the same container for all your tenants and then use a custom folder for each tenant. Or a custom container for every tenant and then the same path. You can also ask for the container to be created and it will be done when the tenant is started. You can read more about this feature in the documentation. Trumbowyg 2.21.0 and resizimg plugin Orchard Core using Trumbowyg, a lightweight WYSIWYG editor, that makes easier to edit your HTML content. Thanks to Antoine Griffard, Orchard Core now using version 2.2.10, including the resizimg plugin. For instance, when you set the Trumbowyg as the editor type of your HtmlBodyPart and insert a media with URL, you can just simply set the size of the image with a friendly user interface. Use GetLanguageDirection method everwhere When you check the content of the OrchardCore.Localization.Abstractions module, you will find a GetLanguageDirection extension method in the LanguageDirection static class. This method is used to get the language direction for a given culture. So, if we have an extension method like this, let's use it everywhere in the code. For example, check the code of the CultureDir extension method in the RazorHelperExtensions class, where you can see an example usage of the GetLanguageDirection method. Fix localization accessors names In ASP.NET Core we have many ways to use localization. The IStringLocalizer interface represents a service that provides localized strings and the IHtmlLocalizer interface provides localized HTML content. In Orchard Core, we used T, S, H, TS and TH, so it's time to unify these names and avoid the confusion. From now in the source code, the S will be used for the IStringLocalizer and the H will be used for IHtmlLocalizer. When localizing the views, the name T will be used like before. Scoped Liquid TemplateContext The goal was to improve perf on the Liquid rendering because we were creating a new TemplateContext and resolving all the services for each template. Here the idea is to create a shared Liquid TemplateContext only once per scope for perf, on which we do once a shared contextualization and then a specific contextualization before each rendering. Shared contextualization is done once per scope: add scoped services in ambient values, call Liquid handlers to add more ambient/scope values and access strategies, add all scoped Liquid filters. Specific contextualization before each rendering: e.g contextualize the localizer with the current view context, update the specific model value and its access strategy. And there are many places where we add a ContentItem value to the Liquid scope, we could remove them because now most of the time it is already accessible through Model.ContentItem. Here you can see that there is no need to create a new TemplateContext and add the ContentItem and the Model to it, it's enough to just simply pass the MarkdownBodyPartViewModel. News from the community Orchard Core on Stack Exchange Area 51 Area 51 is the Stack Exchange Network staging zone, where users come together to build new Q&A sites. New site ideas are proposed, discussed, and the best go on to beta. There is a request on Stack Exchange to create a custom community for Orchard Core. If you want to create a community you have to push for an idea and people need to approve and follow that idea. For this, it's needed more people to join and every person can vote for 5 questions and create 5 questions so, the community can continue on to the next stage. If you are interested in, check the FAQ of the Area 51 site and feel free to join the proposal! Orchard Nuggets: How to use Orchard Core without the sample themes? Try to reference the OrchardCore.Application.Cms.Core.Targets NuGet package instead of the OrchardCore.Application.Cms.Targets in your ASP.NET Core web application, that will only add the TheAdmin theme to your solution. In our third Orchard Nuggets post, we show you the differences between these two packages! Check out the other posts for more such bite-sized Orchard tips and let us know if you'd have another question! Orchard Dojo Newsletter Now we have 112 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!