Content Warnings in Orchard Core

Originally posted at: drewbrasher.com/blog/content-warning-module

Sometimes we may want to create some content that some people might not want to see. For example we might want to talk about a movie and say things that would be a spoiler to someone wh…


This content originally appeared on DEV Community and was authored by Drew Brasher

Originally posted at: drewbrasher.com/blog/content-warning-module

Sometimes we may want to create some content that some people might not want to see. For example we might want to talk about a movie and say things that would be a spoiler to someone who hasn't watched it yet or we might want to talk about something or post an image that could cause emotional distress to some people.

A common way that social and messaging platforms accommodate for this is to allow people to set some content as hidden and instead show a warning until the person looking at it indicates that they want to see it.

My personal website (drewbrasher.com) is built on the open source Orchard Core CMS so I decided to write an Orchard Core CMS Module that allows you to put a content warning around some content so that users can decide if they want to see it or not. The module allows you to put a content warning on some inline content inside a MarkdownBody or HtmlBody using a Shortcode or you can add the Content Warning Part to a Content Type to allow you to put a warning on the whole Content Item.

To use the shortcode, you can select it from the Shortcodes menu in the editor toolbar like this:

Screenshot of the shortcode menu

or you can enter the Shortcode directly into the editor like this:

[content_warning 'Spoiler for The Matrix']Trinity was a famous hacker before being freed from the matrix. [/content_warning]

or the shortened alternative syntax:

[cw 'Spoiler for The Matrix']Trinity was a famous hacker before being freed from the matrix. [/cw]

Here is what it would look like:

CW: Spoiler for The Matrix.

To put a warning on an entire content item, like a whole blog post, you would first need to add the Content Warning Part to your Content Type definition. Once you have done that, you can add a content warning to any item of that content type by checking the "Show Warning" box and entering the warning message you want to display to users.

Screenshot of adding a warning to a content item

If you have an Orchard Core CMS site you would like to add this feature to, you just need to add the DrewBrasher.OrchardCore.ContentWarning nuget package to your project and enable the "Content Warning" feature.

You can check out the source code for this module in the github.com/DrewBrasher/OrchardCoreModules Repository.

I am excited to be doing a demo of this module at Orchard Harvest 2024 (orchardcore.net/harvest) and I hope to see you there!

The JavaScript and CSS in this module are based on the Considering content warnings in HTML blog post by Aaron Gustafson.


This content originally appeared on DEV Community and was authored by Drew Brasher


Print Share Comment Cite Upload Translate Updates
APA

Drew Brasher | Sciencx (2024-08-16T03:34:51+00:00) Content Warnings in Orchard Core. Retrieved from https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/

MLA
" » Content Warnings in Orchard Core." Drew Brasher | Sciencx - Friday August 16, 2024, https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/
HARVARD
Drew Brasher | Sciencx Friday August 16, 2024 » Content Warnings in Orchard Core., viewed ,<https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/>
VANCOUVER
Drew Brasher | Sciencx - » Content Warnings in Orchard Core. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/
CHICAGO
" » Content Warnings in Orchard Core." Drew Brasher | Sciencx - Accessed . https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/
IEEE
" » Content Warnings in Orchard Core." Drew Brasher | Sciencx [Online]. Available: https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/. [Accessed: ]
rf:citation
» Content Warnings in Orchard Core | Drew Brasher | Sciencx | https://www.scien.cx/2024/08/16/content-warnings-in-orchard-core/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.