Our blog contains the activity stream of Orchard Dojo: general news, new resources or tutorials are announced here.

Featured tags

IIS
API
All tags >

Add a way to retrieve a UTC now DateTime in Liquid, Responsive Admin Theme - This week in Orchard (04/11/2022)

Add a way to retrieve a UTC now DateTime in Liquid, change the Query Schema editor to Monaco Editor, allowing multiple INavigationManager, and a demo about the responsive Admin Theme! Let's get started! Orchard Core updates Add a way to retrieve a UTC now DateTime in Liquid Orchard Core has a new Liquid helper called utc, which converts a local date and time to the UTC date and time based on the site settings. Let's say we type in the following expressions: utc: {{ "utc" | local | date: "%c" }}local : {{ "now" | local | date: "%c" }}local is the default : {{ "now" | date: "%c" }} This will appear as follows. You can see the current date time in UTC and in the site time zone as well. This new helper is also added to the documentation of Orchard Core. Change the Query Schema editor to Monaco Editor If you have a site set up with the Blog recipe, you have one predefined query, called RecentBlogPosts. You can edit this query under Search -> Queries -> All queries. And as you may notice, the schema editor now uses the Monaco Editor that powers VS Code too. Allowing multiple INavigationManager In the past, if you were trying to have multiple INavigationManagers, you could not do that because the TryAddScoped is replacing the existing implementations. So, to be able to have multiple INavigationManager implementations, you have to use TryAddEnumerable, which adds a ServiceDescriptor if an existing descriptor with the same ServiceType and an implementation that does not already exist in services. And here, you can see that the NavigationShapes class can now handle multiple INavigationManager implementations. Demos Responsive Admin Theme This demo is about a feature that you can see in this pull request to make the Admin Theme responsive. First of all, you can see that fields are listed with the title being at the start point, in this case on the left. So, if you have an RTL text direction, it will be on the right. The cool thing about this is that you utilize more of the width of the screen when the screen is large and you reduce the scrolling if unnecessary. But if you have a smaller screen, the labels go back to the top as what you used to see. We have the same thing for content parts as well. Here you can see how everything appears if you have a wide or a narrow screen. But not everybody may like to see the labels on the left like this, it means this is optional, and by default, nothing will change unless you explicitly change it. This one was done by adding a new StyeSettings section under the TheAdminTheme section to the appseetings.json where you can define classes. If you chose to utilize this, you can add a setting per tenant, and you can customize the look and feel of the Admin Theme for every tenant. And how does this work is the classes are placed by helpers. Let's check out the TitlePart.Edit.cshtml for example. As you can see, the GetLabelCssClasses() and GetEndCssClasses() Orchard helpers read the settings and apply the class names that you have provided in the appsettings.json file. This means that if you want to use this feature, your custom views have to be updated to utilize these helpers. And all the new built-in views of the source code of Orchard Core have to use these helpers in the future. If you would like to know more about this feature, don't forget to check out this recording on YouTube! News from the community Orchard Harvest 2023 For those who are too young to remember, we had Orchard conferences, called Orchard Harvest. And the conference website was available under orchardharvest.org, but unfortunately, it's not anymore. The last one was in 2017 in New York. So, having another get-together is very much overdue. If you would like to see or get a feeling of how this looked like before, we have a couple of mood videos on the Orchard YouTube channel, like this one from the first conference. The point is that we should really think about organizing the next one, and we at Lombiq can take part in that or provide an organizing role with anybody who wants to take part. If you have any feedback or you are looking forward to having a Harvest again, please share your opinion with us by filling out this survey about the upcoming Orchard Harvest! Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 386 subscribers! We have started this newsletter to inform the community around Orchard of 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 Orchard meeting!

Leverage CSPROJ meta information, Lombiq Helpful Libraries - Navigation for Orchard Core - This week in Orchard (29/04/2022)

Adding an AppSetting option to disable SQLite connection pooling, leveraging your CSPROJ meta information and news and updates around the Lombiq Helpful Libraries! Check out our current post to read about the details! Orchard Core updates Remove Lucene from built-in recipes This is about making the built-in setup recipes lightweight: Lucene is a feature that you don't need on every site, especially due to it storing files on the local file system that need to be preserved (i.e., not temp files) it needs special considerations for hosting (you need to take care of those files when moving the app between environments and doing deployments). The goal here is to not enable Lucene by default in the following recipes: Headless: just remove it. Blank: just remove it. Blog: Create an SQL RecentBlogPosts Query and don't enable Lucene by default. Have a separate, non-setup recipe to set up the search just for a frontend search page (i.e., 90% of what happens related to Lucene in the recipe now). Have a second non-setup recipe that runs the previous one and also swaps out RecentBlogPosts with a Lucene Query. And from now you can find two new optional recipes in the TheBlogTheme: Lucene Query Recipe: this recipe runs the Blog Lucene Search recipe and as an example, the recipe replaces the RecentBlogPosts SQL query with a Lucene query. Lucene Search Recipe: this recipe enables the Lucene feature and creates the Search setting, Lucene indices, and permissions. The Recipes and Starter Themes page of the Orchard Core documentation has also been updated to reflect these changes. Leverage CSPROJ meta information Out of the box, a Manifest.cs file is generated, which includes the ModuleAttribute, FeatureAttribute, ThemeAttribute, and so forth, that describe the Orchard Core meta-information about your projects. However, let's say you want to connect available meta properties at the CSPROJ level, i.e., such properties as $(MSBuildProjectName), $(AssemblyVersion), $(PackageTags), to name a few. At its core, you may want to follow a pattern similar to InternalsVisibleTo, i.e. <ItemGroup> <AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo"> <_Parameter1>Test.$(MSBuildProjectName)</_Parameter1> </AssemblyAttribute></ItemGroup> The principles are the same, but in prior versions, the attribute constructors were not available to lean into. Michael W Powell also decided to provide helpful MSBuild Items as a more accessible, self-documenting shorthand input. From now, you can connect available meta properties at the CSPROJ level by leveraging CSPROJ meta information. If you are interested in how to leverage Orchard Core CSPROJ item lists and properties to enrich and get the absolute most from your authoring experience, this is the page you should take a look at! News from the community Lombiq Helpful Libraries - Navigation for Orchard Core The Lombiq Helpful Libraries contains various useful libraries that can be handy when developing for .NET, ASP.NET Core, and Orchard Core, to be used for your own projects. This time we would like to show you two helpful abstract classes: the NavigationProviderBase and the MainMenuNavigationProviderBase. NavigationProviderBase: an abstract base class for creating reducing boilerplate in INavigationProvider for checking the name parameter and if the user is authenticated. MainMenuNavigationProviderBase: an abstract base class derived from NavigationProviderBase for creating a home page menu structure using the main navigation name. If you use the Lombiq.BaseTheme automatically displays the generated menu as a widget in the Navigation zone. There is a Lombiq.HelpfulLibraries.Samples project for various examples in the form of an Orchard Core module. And that project contains a class called HelpfulLibrariesNavigationProvider. This class inherits the MainMenuNavigationProviderBase, which overrides the NavigationName with the "main" value. And if you check out the sample code here, you can see some other interesting stuff, like how we set up where to navigate users when they click on the given menu items. .ActionTask<LinqToDbSamplesController>(context, controller => controller.SimpleQuery())) In this case, we say that let's navigate the user to the SimpleQuery action of the LinqToDbSamplesController. And of course, you have the option to provide additional arguments as well if you check out the NavigationItemBuilderExtensions static class. Orchard Dojo Newsletter Lombiq's Orchard Dojo Newsletter has 247 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 Orchard meeting!

How to add a breadcrumb menu in Orchard Core - Orchard Core Nuggets

A breadcrumb menu is a simple but effective navigation aid that shows the user where they are in the site's content structure and which path they can take back. It's also part of the web accessibility guidelines. However, there's no feature built into Orchard Core for this. Nevertheless, how to create a breadcrumb menu? It's actually really easy, you just have to copy a piece of code from Orchard Dojo! Oh wait, we're Orchard Dojo. So here you go: @inject OrchardCore.ContentManagement.IContentAliasManager ContentAliasManager; @inject OrchardCore.ContentManagement.IContentManager ContentManager; @inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor; @using OrchardCore.ContentManagement; @using OrchardCore.Menu.Models; @{ // Retrieving the menu we want to build the breadcrum menu for, in this case the one with the alias "main-menu". var menu = await ContentManager.GetAsync(await ContentAliasManager.GetContentItemIdAsync("alias:main-menu")); // We'll need the current URL to be able to check which menu item corresponds to the page. var currentRelativeUrl = HttpContextAccessor.HttpContext.Request.Path; var breadcrumbItems = new Stack<ContentItem>(); // Building the path in the menu tree to the current item. bool SearchActiveItem(IEnumerable<ContentItem> menuItems) { if (menuItems == null) return false; // Note that for the sake of simplicity this will work only with Link Menu Items, not with Conten Menu Items. foreach (var menuItem in menuItems.Select(item => item.As<LinkMenuItemPart>()).Where(item => item != null)) { if (!string.IsNullOrEmpty(menuItem.Url)) { var url = menuItem.Url; if (url.StartsWith("~")) url = url.Substring(1); if (url.Equals(currentRelativeUrl, StringComparison.OrdinalIgnoreCase)) { breadcrumbItems.Push(menuItem.ContentItem); return true; } else { if (SearchActiveItem(menuItem.ContentItem.As<MenuItemsListPart>()?.MenuItems)) { breadcrumbItems.Push(menuItem.ContentItem); return true; } } } } return false; } SearchActiveItem(menu.As<MenuItemsListPart>().MenuItems); } @* Using the Bootstrap breadcrumb classes. *@ <ul class="breadcrumb"> <li class="breadcrumb-item"> <a href="@Url.Content("~/")">@T["Home"]</a> </li> @while (breadcrumbItems.TryPop(out var menuItem)) { var linkItem = menuItem.As<LinkMenuItemPart>(); <li class="breadcrumb-item"> <a href="@Url.Content(linkItem.Url)">@linkItem.Name</a> </li> } </ul> Wait, wait, slow a bit down. What is this? This is the code that would render a simple breadcrumb menu for the menu with the alias "main-menu". If you've set up your Orchard site with any of the built-in recipes you already should have such a menu. But do take a look at the code in detail, we have a lot of helpful comments in there! Once you're clear on what this piece of code does you can copy it somewhere in your theme to display it. For example, you can just put it into the Layout shape template. A cleaner approach would be to put it into its own separate template, like BreadcrumbMenu.cshtml, and display it in one of the many ways possible. Pretty much that's it! Now let's suppose you built e.g. a menu like this: With the above snippet you can have a breadcrumb menu like this when you open the Module Development page: This just uses the default Bootstrap breadcrumbs styling. And that's it, we're done with our breadcrumbs, enjoy! To be fair, this could use some work to make it bulletproof. We could e.g. optimize away the whole lookup when we're on the homepage. Then, it only supports only a single menu item for a given page. Nevertheless, it should get you going. If you'd like to see a generic and more advanced breadcrumb menu feature in Orchard check out this issue. 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!

Getting up to speed with Orchard - Dojo Course

UPDATE (2017-11-22): Dojo Course 2 is released with new, updated videos! How to run Orchard as a developer? What are other, more advanced built-in modules I should know about? Our second Dojo Course tutorial aims to give anwers to these questions. The notes for this tutorial: Download Orchard Source 1.7.1 to run Orchard from source What is Orchard.sln When you starting working, create a copy of Orchard.sln, e.g. DojoCourse.sln A quick glance at the folder/solution structure: built-in modules, the default project (Orchard.Web) is the heart of Orchard NB: VS2012 uses IIS Express instead of Cassini web server Built-in vs. core modules CommonPart settings Tour of the Navigation feature, integrated since Orchard 1.5: menu item types, reordering menuitems, extensibility Demo: creating pages and corresponding menu items Renewed media management enhanced with content types: Media Library (since 1.7) Importing media with drag&drop Editing imported media items, creating folder structured and drag&dropping items between folders Resizing pictures inside of Media Library Guide to the built-int modules Continuously updated source code for the Course (you can upload the latest source in a zip from here) Remember: if you have any questions don't hesitate to ask them by creating a new issue in the Orchard issue tracker with the "discussion" label. Make sure to prefix your thread's title with "Dojo Course - "! We keep an eye on these issues. Haven't you enrolled yet? Why not do it some time in the near future like right now?