Foros de discusión

Use user role data in web content

John Snow, modificado hace 6 años.

Use user role data in web content

New Member Mensajes: 5 Fecha de incorporación: 8/06/17 Mensajes recientes
So in liferay editor I have one web content page that I would like to add a user role check to. But only to certain part inside it.

So my question is. How can I get logged in user's role(s) and then use that role to hide or show certain html row.

Something like this:

if(userRole == "someWeirdRole") {
<div>Show this content</div>
}

But like I said I would only like to use this on this one web content page. Also I can't use permisions cause I don't want to hide the whole page but just some of it's content.
thumbnail
Olaf Kock, modificado hace 6 años.

RE: Use user role data in web content

Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
John Snow:
My question is. How can I get logged in user's role(s) and then use that role to hide or show certain html row.

You're best creating a structure with a template: Have a role name accompany an HTML text (they're nestable) and write the active content (your check for role membership) in the template.

A template can access Liferay's API and the current user, and contain active content. Web Content Articles themselves can not.
John Snow, modificado hace 6 años.

RE: Use user role data in web content

New Member Mensajes: 5 Fecha de incorporación: 8/06/17 Mensajes recientes
Hey! Thanks for the feedback.

Is it possible to do something like this. In WYSIWYG editor there is a content that the editor added. In source I added id to the a link like


<p>This is some content</p>
<a href="#" onclick="somefunction()">Click me</a>
<p>Some more content</p>


But then when I create the template in liferay it overrides my content from editor and displays the content from the velocity template instead.

I would like to display an alert message when user clicks on the link
thumbnail
Shivam Aggarwal, modificado hace 6 años.

RE: Use user role data in web content

Regular Member Mensajes: 122 Fecha de incorporación: 18/01/12 Mensajes recientes
Where exactly do you wish to check for permissions?You need to check for permissions in template and accordingly it will checked as per the template over the content.