This week in Orchard - 05/17/2019

Gábor Domonkos's avatar
Social, Permissions, Localization, Documentation, This week in Orchard

In our post, we would like to give you some tips about how to write localizable text in Orchard Core. We check the new User liquid filters, the new Twitter integration and many more!

On Orchard Core

Add various User liquid filters

We already had the User object in liquid and now we have the has_permission filter to check for named permission and optionally a resource to check for. We have the is_in_role filter to check if the user is in the role and the has_claim filter to check if the user has a claim of the specified type.

Workflows Internalization

This PR has three changes related to localization. First of all, the State text in the OrchardCore.Workflows/Views/Workflow/Details.cshtml file was not translated.

The second one is more interesting. In the OrchardCore.Workflows/Views/Workflow/Index.cshtml we render the status of the workflow. The status can be Idle, Starting, Resuming, Finished and so on. This is an enumeration. These will be rendered as is in the output, they were not translated. Translating as you can see here could be fine because it's just a static value.

The issue is nobody will be able to translate them because we don't know they have to be translated. The solution, in this case, is to use a switch statement. So, enums should be localized using a switch statement that resolves to calls to T[] with the static string inside it. This way our tool will be able to pick it up and add the entry in pot files.

The last point for translation is tricky. It's not a dynamic value (a class) and it can't be solved with a switch. The solution here is to add a new property on the activity to return a localized string, like DisplayText.

Add create new option to Publish and Save Draft buttons

Now we have a Publish button with one suboption called Publish and continue.This PR extends this and adds a new suboption which is Publish and create new. The Save Draft button will also get a new option to Save Draft and create new.

Twitter client and update status workflow activity

In this PR, Michael Petrinolis extends Twitter Module with a Twitter API client and an Update Twitter Status workflow task. To use the new Twitter integration and the new Update Twitter Status activity, you need to enable the Twitter Integration module.

Now you can navigate to the Twitter Integration page in the admin site, where you need to provide four different settings:

  • API key: The API key defined in the Keys and tokens tab of the Twitter app dashboard.
  • API secret key: The API secret defined in the Keys and tokens tab of the Twitter app dashboard.
  • Access Token: The Access Token defined in the Keys and tokens tab of the Twitter app dashboard.
  • Access Token Secret: The Access Token Secret in the Keys and tokens tab of the Twitter app dashboard.

To get these settings, you need to create a new Twitter application where you can get these values.

Now you can use the new Update Twitter Status Task. Let's say we would like to post a new tweet when a new blog post has been published to our site. We can use the Content Published Event as a startup task and set the Blog Post content type to filter on. After add the Update Twitter Status Task and provide a title and a template for updating Twitter status.

Bethany Christian Services using Orchard Core

Bethany Christian Services using Orchard Core for their website. Bethany believes every child deserves to be loved, connected and empowered through the family. Bethany is a global nonprofit that supports children and families with world-class social services, all designed to help families thrive.

APS Medical Billing Solutions using Orchard Core

APS understands that it takes experience to run a successful healthcare business, and they are dedicated to finding solutions that fit your specific practice requirements. The team of qualified medical billing specialists work with each practice to create value through customized service.

If you are interested in more websites using Orchard and Orchard Core, don't forget to visit Show Orchard. Show Orchard is a website for showing representative Orchard CMS (and now Orchard Core) websites all around the internet. It was started by Ryan Drew Burnett, but since he doesn't work with Orchard anymore, as announced earlier it is now maintained by our team at Lombiq Technologies.

On Lombiq

Orchard Dojo Newsletter

Now we have 61 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 every time when 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