<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Drew Brasher</title>
    <description>The latest articles on DEV Community by Drew Brasher (@drewbrasher).</description>
    <link>https://dev.to/drewbrasher</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F307922%2F9a95d43f-706c-4951-9c9c-153511a7cc0b.jpg</url>
      <title>DEV Community: Drew Brasher</title>
      <link>https://dev.to/drewbrasher</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/drewbrasher"/>
    <language>en</language>
    <item>
      <title>Content Warnings in Orchard Core</title>
      <dc:creator>Drew Brasher</dc:creator>
      <pubDate>Fri, 16 Aug 2024 03:34:51 +0000</pubDate>
      <link>https://dev.to/drewbrasher/content-warnings-in-orchard-core-jl3</link>
      <guid>https://dev.to/drewbrasher/content-warnings-in-orchard-core-jl3</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally posted at: &lt;a href="https://drewbrasher.com/blog/content-warning-module" rel="noopener noreferrer"&gt;drewbrasher.com/blog/content-warning-module&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;My personal website (&lt;a href="https://drewbrasher.com/" rel="noopener noreferrer"&gt;drewbrasher.com&lt;/a&gt;) 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.&lt;/p&gt;

&lt;p&gt;To use the shortcode, you can select it from the Shortcodes menu in the editor toolbar like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmme0blhg2b7e7b1ewo33.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmme0blhg2b7e7b1ewo33.jpeg" alt="Screenshot of the shortcode menu" width="708" height="355"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or you can enter the Shortcode directly into the editor like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[content_warning 'Spoiler for The Matrix']Trinity was a famous hacker before being freed from the matrix. [/content_warning]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or the shortened alternative syntax:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[cw 'Spoiler for The Matrix']Trinity was a famous hacker before being freed from the matrix. [/cw]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is what it would look like:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuq3rj1ukukweqfqolos.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuq3rj1ukukweqfqolos.png" alt="CW: Spoiler for The Matrix." width="800" height="62"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6abrr4n9sywqrlzu09mw.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6abrr4n9sywqrlzu09mw.jpeg" alt="Screenshot of adding a warning to a content item" width="201" height="105"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have an Orchard Core CMS site you would like to add this feature to, you just need to add the &lt;a href="https://www.nuget.org/packages/DrewBrasher.OrchardCore.ContentWarning" rel="noopener noreferrer"&gt;DrewBrasher.OrchardCore.ContentWarning&lt;/a&gt; nuget package to your project and enable the "Content Warning" feature.&lt;/p&gt;

&lt;p&gt;You can check out the source code for this module in the &lt;a href="https://github.com/DrewBrasher/OrchardCoreModules" rel="noopener noreferrer"&gt;github.com/DrewBrasher/OrchardCoreModules&lt;/a&gt; Repository.&lt;/p&gt;

&lt;p&gt;I am excited to be doing a demo of this module at &lt;a href="https://orchardcore.net/harvest" rel="noopener noreferrer"&gt;Orchard Harvest 2024 (orchardcore.net/harvest)&lt;/a&gt; and I hope to see you there!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The JavaScript and CSS in this module are based on the &lt;a href="https://www.aaron-gustafson.com/notebook/considering-content-warnings-in-html/" rel="noopener noreferrer"&gt;Considering content warnings in HTML&lt;/a&gt; blog post by &lt;a href="https://github.com/aarongustafson" rel="noopener noreferrer"&gt;Aaron Gustafson&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>orchardcore</category>
      <category>contentwarning</category>
      <category>contentmanagement</category>
    </item>
  </channel>
</rss>
