Orchard Harvest 2023, User Notifications - This week in Orchard (28/10/2022)

Gábor Domonkos's avatar
Admin UI, Announcement, This week in Orchard, Content field, Theme, Workflows, Widget

Adding default form templates for the Default Theme, adding wrapper element for all content fields, demo about the User Notifications module and don't forget to fill out a survey about the next Orchard Harvest conference!

Orchard Core updates

Adding default form templates for the Default Theme

Currently, all of the form widgets are rendered using Widget.cshtml which renders too much HTML without any added value. The goal here is to create default Widget-Form, Widget-Input, Widget-Label, Widget-Select, Widget-TextArea, Widget-Validation, and Widget-ValidationSummary templates. It means that now, you will find these default form templates if you open up the Default Theme.

Default form templates for the The Default Theme

Adding a wrapper element for all content fields

There is no easy way to hide/show content fields "label and input as a group" using JavaScript event because there is no wrapper element to select. The goal here is to add a wrapper element to all of the content fields to allow the user to easily hide/show the entire field block using JavaScript. Here you can see the editor of the Text Field where the wrapper has now new classes with ones that you can easily use to distinguish the same kinds of Text Fields from each other.

Add a wrapper element for all content fields

For example, the Text Field called Subtitle of the built-in Blog Post content type has the following HTML structure. Here you can see that the third class and the ID contain the technical name of the Text Field, which makes targeting the given field easier.

Updated wrapper of the Subtitle Text Field

Adding GetPageSize method to account for MaxPageSize throughout the code

Now we have a new GetPageSize method in the PagerOptions class that returns the maximum number of the allowed page size based on the values of the default and maximum page size numbers. And we are using the value coming from this method for every occurrence, where we are constructing the Pager by passing it as the second parameter. Which is the default page size in this case.

New GetPageSize method in the PagerOptions class

Demos

User Notifications

The goal of the User Notifications module is to push notifications to the user, meaning notify the user somehow. There are many ways you can notify a user, one of them being a web notification, you can do SMS, you can do push to a mobile application, etc. In Orchard Core right now, there is no way to send notifications, but there is a way to send emails. Let's navigate to Configuration -> Features and enable the Notifications module. This will provide a way to notify users. After you enable this module, you will see a new bell icon near the Dark mode icon at the top right. If you click on that icon, you will see a list that shows you all of the notifications that you have right now. You can click on them to mark them as read, or you can click on All Notifications at the bottom, which will redirect you to the page where you can see all of your notifications.

Displaying the notifications list when clicking on the new bell icon

Here you can see a list of all of the notifications available. You can use the search here, and filter them only to see the read or the unread notifications. You can sort by recently created, or by previously created. You can also mark the unread notifications as read, mark the read notifications as unread or you can delete the notifications as well. You can also hit the Mark All As Read button to mark everything as read.

Manage Notifications page

Now let's see how you can generate notifications! Notifications can be generated via code by injecting INotificationManager. But you can also generate notifications via Workflows. Here you can see we have a workflow called Notify Content Owner, which contains the custom activities provided by the Notifications module. Here we put two events, one for when the Blog Post content item is published and one for when the Article is deleted. And here, you can also see the two new Notify content's owner activities as well.

The Nofify Content Owner workflow

Let's check out the content of the first Notify content's owner activity! Here you can see we have proper Liquid support to customize the summary, and the body of our notification.

Activity to notify the content owner when a blog post is published

If we open up the editor of the second Notify content's owner activity, you can see here we have some HTML code in the body as well. To be able to render the HTML properly, don't forget to put a tick in the "The body contains HTML" checkbox.

Activity to notify the content owner when an article was deleted

And that's not everything! If you would like to know don't forget to check out this recording on YouTube! And if you want to try out this feature for yourself, you can find the code in this PR!

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 are you looking forward to having a Harvest again, please share your opinion with us by filling out this survey about the upcoming Orchard Harvest!

Orchard Harvest conference 2023 survey

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 381 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!

No Comments

Add a Comment