make a component appear only when the current environment is not-closed
Hi all,
On our Community we have closed sections where we test new products together with select users. We want to create a friendly warning when new testers are about to post outside of closed environments. This way we want to prevent leakage of sensitive information about not released products.
I need to build notifications for users with a specific role (product testers) when they are about to make a new topic - or placing a comment - outside of a closed forum.
I did search for info on how to show components based on detection closed, hidden or open environments, but didnt find what I was looking for, so:
How can I make a component appear only when the current environment is not closed (and the user has a specific user role)?
With that figured it I can look to add it to the editor section on a topic, and add it to the new message page. Tips are welcome.
PS. I would really love to have parentnode and visibility (open, hidden, closed) added to the datalayer LITHIUM.CommunityJsonObject.Page - and userrole added to LITHIUM.CommunityJsonObject.User.
Based on your use case I would recommend checking out the blog post on access signposting by SuzieH because it sounds like it accomplishes similar to what you’re looking for.
You could consider doing this via a custom quilt for the topic creation page / blog post page, with a custom component or custom content component that contains the warning message you want to display. You’d need to manually set the quilt for the closed areas.
Maybe not the most satisfying approach, and its feasibility depends on the number of closed areas you have... but it'll work.
Hopefully someone has a more technical / API-based answer!
Based on your use case I would recommend checking out the blog post on access signposting by SuzieH because it sounds like it accomplishes similar to what you’re looking for.
Jeff, thanks! Following the link you have shared I see suggestions how to make an IF statement using UserRoles and CoreNode ID's and CoreNode Ancestors.
With this I should be able to make a component appear for Testmembers when the current node is not a test environment and they are about to write a comment.
The real challenge will be to add a component to the postpage (start a discussion page). Can I even do that using the page and component editors in studio?
Yeah, depending on where you're wanting to place the component (e.g. banner across the top of the page, etc.) then you can just add the component to the PostPage quilt.
In our environment I even had to get a bit more creative since the new support case form in the Case Portal also utilizes the PostPage and I wanted the editor to be two-thirds width in the Case Portal with a right rail for case information/policies (not unlike the Case Portal in Atlas) but wanted the editor to span the full width everywhere else.
So I decided to create a custom layout for the PostPage which is shown below.
In my layout I keep the main-content section for most discussion styles, and then created the support-main-content and support-side-content sections to be specific to the Case Portal.
This is what the XML for my PostPage quilt looks like:
I wanted to be able to call the out-of-the-box editor component in both locations without actually rendering it twice and without having to create two separate custom components. (My Components tab in Studio is long enough already!),
So I wrapped the editor component in a custom component called custom.postPage.editor (shown below) and I included it twice in my quilt, while defining a component parameter called casePage in only one of them.
<#-- Get the casePage component parameter value if defined -->
<#assign casePage = env.context.component.getParameter("casePage")!"false" />
<#-- Convert the parameter value to Boolean -->
<#if casePage == "true">
<#assign casePage = true />
<#else>
<#assign casePage = false />
</#if>
<#-- Define when the rich-text editor should be rendered -->
<#if page.name == "PostPage">
<#if casePage?? && casePage && page.interactionStyle == "support">
<#-- Only render within the Case Portal -->
<@component id="editor"/>
<#elseif (!casePage?? || !casePage) && page.interactionStyle != "support">
<#-- Only render when not within the Case Portal -->
<@component id="editor"/>
</#if>
</#if>
I know this is probably a weird use case but hopefully it helps illustrate how you can bend the PostPage to your will in Studio. 😊
Thanks a lot for the detailed help jeffshurtliff! It has been months, I have totally missed this one. Nice to see you have built a custom layout for the postpage, I'll keep that in mind! Great tip.