Forum Discussion
If there is a different role for different node, then you need to use below code using corNode id
<#assign content =
restadmin("/boards/id/${coreNode.id}/settings/name/customcontent.#_text").value
/>
If checking for just same role on all the nodes then you can just use this one
<#assign content =
restadmin("/settings/name/customcontent.#_text").value
/>
Thanks VikasB,
Although maybe we're not on the same page? The component will be testing if there's a role declared within customcomponent.#_text, similar to....
if customcomponent.#_text contains a users.role and it matches the current users.role display customcomponent.#_title and text with appropriate HTML else do not display anything
The custom component text field would then be declaring different roles and a unique message
if users.role = "beginner" display "Welcome to the Community" elseif users.role = "expert" display "Welcome back"
That's not specific to what I'm trying to do, but the best way I can think to elaborate on what I'm trying to achieve.
Thanks again for all your help.
- VikasB8 years agoBoss
Get value from Custom Content #
<#assign role =restadmin("/settings/name/customcontent.#_text").value />
Compare it with user role
<#if role == 'Beginner' > Welcome <#elseif role=='Expert'> Welcome Back <#else> <#--Nothing to display -> </#if>
Hope, you are trying to do something similar. LMK if you want something else.
- Kev_B8 years agoAdvisor
Thank you, I think it's definitely similar. I'll have to experiment and see how it turns out.
Appreciate your tips and advice.
- Kev_B8 years agoAdvisor
Just wanted to add in the solution I found for this, in case anybody else is doing similar.
I pulled the text field of our Custom Content, then ran a LiQL query to pull a users' roles based on their user ID.
I then ran through listing the returned role values, comparing them with the contents of the Custom Content field, using the ?contains built-in in FreeMarker.
Then ran a conditional to display the Custom Content component if there was a match, otherwise to hide the component.
If anybody has any suggestions for a simpler solution, I'd love to hear it. Obviously would've been a bit easier if there were a Context Object to pull the user's roles.
My next stage is to then add conditionals into Custom Content to decide which message to display to which rank, but that should be straightforward having built the component to show or hide the CC component based on the roles matching those of the user.
Related Content
- 9 days ago
- 2 months ago
- 2 months ago
- 2 months ago
- 2 months ago