Add new permission to allow editing content owner, add new GetAsync extension - This week in Orchard (17/03/2023)

Gábor Domonkos's avatar
Documentation, This week in Orchard, Content part, Workflows

Updating Workflows documentation, adding new permission to allow editing content owner, and adding new GetAsync extension. Interested in the details? Well, then check out our post for the details!

Orchard Core updates

Update Workflows docs

Let's say you have a workflow event (implemented EventActivity), and you want to print a property value using Liquid when using a for loop like this:

<h4>Here is the responses</h4>
    {% for item in Workflow.Input["ThresholdSummaries"] %}
        <li>The response to '{{ item.Title }}' was '{{ item.Respond }}' while threshold is '{{ item.Threshold }}'</li>
    {% endfor %}

However, the notification replaces {{ item.Title }}, {{ item.Respond }}, and {{ item.Threshold }} by empty string instead of the actual value. The reason for that is from memory, you need to define a Liquid MemberAccessStrategy for this custom type to allow its properties to be accessed.

The Orchard Core documentation has been updated to describe how you can trigger a custom event activity and register a member access strategy if you are looking to use Liquid to access the member of a custom object.

The updated Workflows documentation page

Add new permission to allow editing content owner

Currently, SiteOwner permission is required to be able to see/edit the Common Part info like the owner. Let's say you want to allow a moderator to change the owner of a specific content type. Currently, there is no way to do that without granting moderators SiteOwner which isn't acceptable.

From now on, we have EditContentOwner and EditContentOwner_{} permission to control who can edit the owner of a content item when Common Part is attached.

Let's see this quickly in action! Here we assume that you set up your site using the Blog recipe. First of all, we have to make sure that we are logged in with a user who has permission "Edit the owner of a content item permission". If you check out the permissions of the Administrator role, you will see that users within this role have this permission by default.

The new edit content owner permission

Now, we will modify the content definition of the Blog Post content type a little bit, and attach the Common Part to it. We can do it under Content -> Content Definition -> Content Types where we need to hit the Edit button near the Blog Post. After that, we can simply add the Common Part to the Blog Post. Before finalizing editing the content definition, don't forget to edit the Common Part settings and put a tick into the "Display owner editor" checkbox.

The Display owner editor checkbox option of the Common Part settings

It's time to see the result of our work! We have one predefined blog post on the site, so we will edit that one. And as you can see, the first textbox here is the one called Owner (we can move this textbox anywhere of course) with the value "admin". That's because the username of our super user is "admin" and we set up the site with this user. And of course, now you can modify the owner user of this content item. But don't forget, here you have to provide the user's name of an existing user. In the following screen, we tried to change the owner to "admin2" but we faced an error because we don't have a user with that user name in our system.

Utilizing the Owner textbox

Add new GetAsync extension

Currently, we have GetAsync(IEnumerable<string> contentItemIds, bool latest = false) and GetAsync(string contentItemId, VersionOptions options) but not GetAsync(IEnumerable<string> contentItemIds, VersionOptions options).

When doing a bulk update, it is much more helpful to use GetAsync(IEnumerable<string> contentItemIds, VersionOptions options) than GetAsync(IEnumerable<string> contentItemIds, bool latest = false) if we want to get multiple VersionOptions.DraftRequired, not just the latest. And here you can see the new GetAsync method, which accepts the contentItemIds and the VersionOptions!

The new GetAsync extension

News from the community

Orchard Dojo Newsletter

Lombiq's Orchard Dojo Newsletter has 412 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 about 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