Named style and script Tag Helpers, This is Lombiq! - This week in Orchard (09/05/2020)

Gábor Domonkos's avatar
Announcement, Documentation, This week in Orchard, Theme

Have you ever developed a great feature for Orchard Core that you wanted to add to the source code, but you were not sure about how to contribute the code and submit a pull request? And do you want to know the team behind all that we do at Lombiq Technologies? Here are all the faces, the whole Lombiq team. This is Lombiq! Don't hesitate and check our current post for more!

Orchard Core updates

Make Login, Logout and ChangePassword paths configurable

Now you can change the endpoints for the login URLs. These can't be changed by using code, that's why they had to be in the appsettings.json. You can find the correct way about setting these values in the documentation.

Custom path for user endpoints

How to contribute?

Since now there weren't any pages where you can find details about how you can contribute your source code back to Orchard Core. Now if you checkout to the dev branch of Orchard Core you will find a CONTRIBUTING.md file in the root of the repository which tells you everything about how to contribute code and content, submit pull requests and so on.

Documentation about how to contribute

Allow registering named style and script resources with inline content

You have Liquid and Razor tags for custom styling/custom scripts and the ability to say where you want your style/script to be rendered. And if you inject a custom script/styling you can set the dependency of your custom script/style.

Let's see some Razor example for these additions! Imagine that you would like to add a custom script for your page and use the ID selector from jQuery to select a single element with the given ID attribute. For that, you will need to include jQuery for your page. To do that you have 2 options:
Register your script using the IResourceManifestProvider, set the dependencies of your script (for example jQuery), and just simply use the script Tag Helper to inject that to your Razor page.

<script name="myVeryCustomScript" asp-src="~/areallycustomscript.js" at="Foot"></script>

But you can also set the dependency here by using the depends-on attribute.

The second way is to add a custom script and say that you are using jQuery functions, so you will need jQuery to be able to run your script.

<script at="Foot" depends-on="jQuery">
   $('#myDiv').css('border', '3px solid red');
</script>

In both cases, you inject your script in the wanted location (foot or head) and set the dependencies of the page. That's great, but imagine that this script is in the template of a widget. And of course, a page can contain several instances of your widget. In that case, your script will be injected multiple times. In some cases, that's what you want, but if not, it's unnecessary to have that script on the page multiple times. You have several workarounds to check if the script/styling is already injected to the page or not, but now you have an easier solution for that. Let's see the following code:

<script name="MyScript" at="Foot" depends-on="jQuery">
   $('#myDiv').css('border', '3px solid red');
</script>

The only difference here is the name attribute and this makes this block a named script. Named scripts will only be injected once and can optionally specify dependencies. You can use the style Tag Helper in the same ways:

<style name="my-style" depends-on="the-theme">
   .my-class {
      /* some style */
}
</style>

Adding option to enable MiniProfiler on the admin too

The MiniProfiler module can only display its little widget on the frontend currently. Now you have an option to enable it for the admin too. To see it in action set the option, which can be done in OrchardCore.Cms.Web's Startup class with this snippet:

public void ConfigureServices(IServiceCollection services)
{
   services.AddOrchardCms(builder => builder.ConfigureServices(services =>
   services.PostConfigure<MiniProfilerOptions>(options =>
   {
      options.AllowOnAdmin = true;
   })));
}

Or you can use the AllowMiniProfilerOnAdmin() extension method in the same method:

public void ConfigureServices(IServiceCollection services)
{
services.AddOrchardCms(builder => builder.AllowMiniProfilerOnAdmin());
}

For more information about the Mini Profiler head to the documentation, where you can also find a link to the updated Configuration page.

Documentation about how to configure IOptions from code

Fix RSS items description

The issue in the screen below was that if the bodyAspect was not null, we are reused the bodyAspect. The bodyAspect was cached during a request, but if you are rendering many different content items, then we would reuse the same bodyAspect for all of them. In an RSS feed when we build the body of the content items, all the RSS items would have the same body. Now we are also caching the content item ID. If we don't match the exact content item ID we don't restore the cached version of the body. Check the diff in the HtmlBodyPartHandler! Here you could see the related code changes where we also cache the content item ID.

Caching the ContentItemId in HtmlBodyPartHandler

Demos

Kast Group Finder: an Orchard Core site

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 YouTube video about what can you achieve by using Orchard Core and how you can use the Group Finder and let us know if you have any questions!

News from the community

RC2 branch

If you navigate to the GitHub page of Orchard Core and check the issues, you will find one with the name RC2 Validation. There is a list that contains all the things that are needed to be done to ship RC2. Here you can find a branch that contains the list of to-dos to work on.

Items to do to release RC2 branch

In this checklist, you can find the items that needed to do when publishing a release. You can check this issue from time to time to monitor the current state of the RC2 release.

New Orchard Nuggets posts

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, just copy a piece of code from this brand new Orchard Nuggets post!

Orchard Nuggets Breadcrumb menu

Let's suppose you're building your shiny new Orchard Core website. In there you're also building a shiny new page, with Flow Part obviously. You throw together a lot of widgets to get all the bells and whistles on the page, then you save it and BAM! Internal Server Error: "InvalidDataException: Form value count limit 1024 exceeded." What's this, did I break Orchard? Is Orchard trying to break me? Let's find out how to fix this in the second Orchard Nuggets post of the week!

This is Lombiq!

Do you want to know the team behind all that we do at Lombiq Technologies? Here are all the faces, the whole Lombiq team. All the Orchard developers, leaders, office managers, hardware and software engineers, accountants, advisors! This is Lombiq.

The two projects of ours mentioned in the video are DotNest, the Orchard SaaS (https://dotnest.com/), and Hastlayer, the .NET hardware accelerator (https://hastlayer.com/).

Note that while we published this video during the coronavirus pandemic it was actually recorded during our 2019 RnDay event, in December 2019. Everyone was safe :).

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 142 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!

No Comments

Add a Comment