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

Featured tags

IIS
API
All tags >

Click to deploy improvements, autoroute container routing - This week in Orchard (24/04/2020)

This week we continue the journey with the new upcoming feature of Orchard Core called Click to deploy. But before that, we will check out the new Liquid helpers, the contributors' page, and many more! Finally, don't forget to take a look at our newest Orchard Nuggets post and the improvements in our Orchard Core Training Demo module! Orchard Core updates Themes standardization It can be hard sometimes to keep all the themes updated with the latest changes and improvements of Orchard Core. Now in every theme, you can add a custom template for the title or can use the features of the built-in one. If you check the code of the PageTitle shape in the PageTitleShapes.cs file, you will see the usage of the LiquidTemplateManager that helps you to customize the way how you would like to render the title of your page. We wrote about how to customize the title in Liquid here: https://orcharddojo.net/blog/this-week-in-orchard-09-06-2019. And in some themes, the HeadMeta zone hasn't been used in the layout. Now you have the possibility to show the content of this zone in every theme and rendering this at the end of the head tag. In this case, you can add your custom CSS in this section and have the ability to override the styling of the theme that you are using. Let's check the layout.liquid file of the Coming Soon Theme for these changes. Contributors Orchard Core has more than 150 contributors! The repository of Orchard Core now contains a Contributors.md file, where you can find the profiles of the contributors. They can have different badges, based on the type of work. There are badges for answering questions, doing code reviews, writing blog posts, and so on. Autoroute container routing A few weeks ago we wrote about the new settings of the Autoroute part: Allow contained item routing: Check to allow users to enable routing of child content items. Manage contained item routes: Check to allow this part to apply routes to child content items. Allow absolute path: Check to allow users to enable absolute paths for child content items If you prefer videos you can also find a demo about this feature on YouTube. And now the huge PR that contains this feature is merged in the dev branch of Orchard Core! Would you like to try this out yourself? Use the latest changes of dev branch now by adding this OrchardCore-preview MyGet URL to your NuGet sources: https://www.myget.org/F/orchardcore-preview/api/v3/index.json as it described here. Thanks for this great feature for Dean Marcussen! Add support for DictionaryAttributePrefix and ModelExplorer property in Liquid You can find an OrchardCore.Demo module in the source of Orchard Core. The goal of this project is to show you the different features of Orchard Core by providing great sample codes. This project has been updated with the latest Liquid helpers. If you open the TodoController.cs in the module, you will find the endpoints of a simple To-do app. But that's not the interesting part. There are 4 related Liquid files in the module. Two in the Todo folder in the Views called Edit.liquid and Index.liquid and two in the root of the Views folder called Todo.Edit.liquid and Todo.liquid. Here comes the content of the Index.liquid file. Here you can see a simple table contains the to-do items. But after the table, there is a button that navigates the users to a page where they can create new to-do items. You can see the block Liquid helper here and the way about how to set the route values for the button. So, if you click on that button you will be navigated to the Create action of the TodoController, that is about to render the Todo.Edit.liquid shape. Here you can also find several new helpers. The form helper is about to render a form and the helper Liquid helper is invoke the input tag helper of ASP.NET Core and binds Text of the Model. If you check the rendered page of the Todo.Edit.liquid file you will see the form that is used to create new to-do items. Every new Liquid helper (form, input, label, validation_summary, validation_for, span) can be found in the Orchard Core documentation. Add icons to Configuration Settings menus When you navigate to the admin UI of Orchard Core and check the root menu items in the navigation bar, you could see that these items have icons. From now, some submenu items are just about to show you some icons too. Head to Configuration -> Settings or Security to see the new ones. Demos Click to deploy improvements If you haven't seen the demo about the upcoming feature called Click to deploy yet, head to YouTube to watch the recording or check out the previous This week in Orchard post because this will be the continuation of the Click to deploy feature. First, navigate to Configuration -> Features and enable the three new features: Add Content to Deployment PLan Click to Deploy Content View or Export Content as JSON Now head to the content items list (Content -> Content Items) and hit the Actions button to open the dropdown. You can see that the context menu is now getting a lot more items. The Export to Deployment Target is about to automatically create a custom recipe file that can be downloaded locally or send it to a remote instance. You can use the Available Targets modal to select the destination. The Add to Deployment Plan is about to add a new content item step using this content item to an existing deployment plan. In this case, a new modal window will open again that lets you choose from the available deployment plans. The Export as JSON is about to directly download the recipe to your computer locally and the View as JSON is a very helpful feature because as you could see in the screen below it shows you the JSON representation of the content item. The same JSON will go to the content step of the recipe when you are hitting the Export as JSON button. Here you have the availability to copy the JSON structure by clicking on the copy icon at the top-right corner of the page. If you are interested in the full demo don't forget to watch the recording on YouTube! Note that this feature is under development and can be found in this branch! News from the community Orchard Core Training Demo module: creating a widget from code We have just added some lines to our Orchard Core Training Demo module to show you the way about creating a new widget from code. In the PersonMigration.cs file we defined a PersonPart, an index table for this part, a Person content type, and from now a PersonWidget. Orchard Core Training Demo module is a demo Orchard Core module for training purposes guiding you to become an Orchard developer. You can use this module as part of a vanilla Orchard Core source that including the full source code - which is the recommended way. You can use it as part of a solution the uses Orchard Core NuGet packages, however, it's harder to look under the hood of Orchard Core features. The module assumes that you have a good understanding of basic Orchard concepts and that you can get around the Orchard admin area (the official documentation may help you with that). You should also be familiar with how to use Visual Studio and write C#, as well as the concepts of ASP.NET Core MVC. Bug reports, feature requests, and comments are warmly welcome, please do so via GitHub. Feel free to send pull requests too, no matter which source repository you choose for this purpose. Orchard Nuggets: How to add a favicon under /favicon.ico in Orchard Core Every website needs a favicon of course and you can easily add one to your Orchard Core site from a theme or module with a link tag in a template. However, there's a catch: Certain browsers will still search for it (as a first attempt) under the path /favicon.ico. This can be a tiny bit detrimental to the client-side performance, and show up as annoying errors in your logs. So what can you do to serve a favicon under that path too? 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! 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 139 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!

How to debug an MSBuild build process when building Orchard Core - Orchard Core Nuggets

Build processes of .NET Core apps like Orchard Core are getting quite complex nowadays, and the MSBuild build pipeline also commonly includes steps for building client-side resources or doing a lot of things out of the .NET world. What can you do if something goes off course with all those targets and props files and you're just scratching your head? How to figure out what happens during the build if you can only see that the results are incorrect? When publishing a .NET Core app or running a build directly use the MSBuild switch /bl. This will create a binary log that exposes a lot of the internal info of the build process. You can pass such build parameters to dotnet publish too. Open the binary log with MSBuild Structured Log Viewer. The tool will show you how exactly the build process runs, what the order of the steps is, how long everything takes… You’ll even be able to see the values of all variables! If you want to check out what was actually included in the assembly, including static resources being embedded, then you can use ILSpy to decompile it. It’s also available as a handy Visual Studio extension. Oh, and BTW if you want to add NPM and Gulp operations to the build pipeline check out our open-source NPM MSBuild Targets project! 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!

How to publish an Orchard Core app - Orchard Core Nuggets

Let's imagine you've already created an Orchard Core app and now it's time to show it to the world. How do you publish it, or rather, how do you create its publish package? When publishing an Orchard Core, or any .NET Core app (be it a desktop app for release or deploying a web app) you need to use the dotnet publish command (see its docs). For web apps running on Azure App Service our usual practice is to do a self-contained deployment, see the .NET Core publishing guidelines. A standard publish command for a 32b Windows App service is as following: dotnet publish SolutionName.sln --configuration Release --runtime win10-x86 --output C:\path-to-package-folder --self-contained true For a 64b App Service the runtime would be win10-x64. If you just want to do a quick debug publish then running dotnet publish in the folder of an Orchard-based web app’s solution without any parameters will create a published app in the YourWebApp\bin\Debug\netcoreapp3.1\publish folder. For a PowerShell script that does a publish and then zips up the package see this script in our HipChat to Microsoft Teams Migration Utility. 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!