留言板

How to show a certain part of a web content which has only one html editor

syouhin ran,修改在7 年前。

How to show a certain part of a web content which has only one html editor

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
I want to show a certain part of a web content which has only one html editor.
I don't know how to use the html editor in that situation. Could someone help me please?
I use liferay 6.2.
Thanks !!!

(Example)
---
<h1>Header</h1>
<script type="text/javascript">
if ( loginUser.role() == "role1" ){
document.write("<b>Role1 can view this part of html only.</b>");
} else if ( loginUser.role() == "role2" ){
document.write("<b>Role2 can view this part of html only.</b>");
}
</script>
<b>Anyone can view this part of html.</b>
<h1>Footer</h1>
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
I don't recommend using JavaScript for this. Instead, I suggest using a web content template. In the template editor, there's a 'Permission Checker' object which you can use to check the user's permission.
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Thank you samuel. I think you mean that:

---
${html_header.getData()}
if ($permissionChecker.getRoleIds() == "role1")
${html_1.getData()}
#else if ($permissionChecker.getRoleIds() == "role2")
${html_2.getData()}
#end
${html_anyone.getData()}
${html_footer.getData()}
---

but my problem is

1, I want to write the html code in one web content.
2, the web content template editor and web content editor have different permissions.
User(edit permission for web content template) > User(edit permission for web content)
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
Can you describe the business use case that you're trying achieve? Trying to do what you want in JS is not very safe since anyone can read the content that was not intended for them.
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi samuel,

Thank you very much for your help.

I want to make an internal website for sharing documents(html page).
Everyone use ipad to read documents, so they do not have chance to modify javascript.

the image is:
(one page = one web content = one html editor)

<html>
<table>
..header content
</table>
<table>
..content only role1 can view
</table>
<table>
..content only role2 can view
</table>
<table>
..content anyone can view
</table>
<table>
..footer content
</table>
</html>

Can I use javascript to make it?
Thanks again!
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
If you're going to do it in JavaScript, than anyone will be able to read the content that only role1 and role2 should read. It doesn't matter that it's an iPad and you won't need to modify the JS to view the content.

What's the reason why you need to do this in a single HTML content area? What's preventing you from giving your content writers permission to create both web content and web content templates? (Alternatively, what's preventing you from your administrator from creating a web content template and letting your web content writers use that template?)
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi samuel,

thank you for your response.

>What's the reason why you need to do this in a single HTML content area?
Do you mean I should create two web page, one page for role1, and the other page for role2?
because both of them have much common content, and if I want to change something of the
common content later, I have to modify the two web page.

>What's preventing you from giving your content writers permission to create both web content
>and web content templates?
Because I have only one web content template, and the web content template has only one html object.
I do not need to maintain the web content template.
Everything is in the web content.
End user can view web page from the URL that links to a web content.

Looking forward to your reply.
Thank you.
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
syouhin ran:

>What's the reason why you need to do this in a single HTML content area?
Do you mean I should create two web page, one page for role1, and the other page for role2?
because both of them have much common content, and if I want to change something of the
common content later, I have to modify the two web page.


No, you don't need to have multiple pages. Just use a web content structure that has multiple text/textarea fields

>What's preventing you from giving your content writers permission to create both web content
>and web content templates?
Because I have only one web content template, and the web content template has only one html object.
I do not need to maintain the web content template.
Everything is in the web content.
End user can view web page from the URL that links to a web content.


You should consider using additional web content structure and templates. It'll make things easier.
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi samuel,

Thank you for your help sincerely .
would you please give me some details about the "web content structure that has multiple text/textarea" and "additional web content structure and templates"?
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
Hi Syouhin,

Have you taken a look at the link to Content Structures and Templates?
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi Samuel,

Thank you for your consistent help.
I will give it a try.

>Have you taken a look at the link to Content Structures and Templates?
It provides very basic information about Structures and Templates.
I am sorry to trouble you, but would you please give me some tips about additional web content structure?
Thank you.
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
What kind of tip do you need? It's easier to help if you have a specific question about structures that you don't understand.
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi Samuel,

sorry for the late reply.

I have made a sample like below.

(Structure)
(html editor)everyone can view
(html editor)only role1 can view
(html editor)only role2 can view

(Template)
$html_everyone.getData()
#foreach($role in $permissionChecker.getUser().getRoles())
#if($role.getName() == "role1")
$html_role1.getData()
#elseif($role.getName() == "role2")
$html_role2.getData()
#end
#end

If I want make a complicated page like below, I must have to make more html editor in Structure.
Am I right?
(Request)
(html editor)everyone can view
(html editor)only role1 can view
(html editor)everyone can view
(html editor)only role1 can view
(html editor)only role2 can view
(html editor)everyone can view

Best Regards
thumbnail
Samuel Kong,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

Liferay Legend 帖子: 1902 加入日期: 08-3-10 最近的帖子
Correct
syouhin ran,修改在7 年前。

RE: How to show a certain part of a web content which has only one html edi

New Member 帖子: 8 加入日期: 16-7-13 最近的帖子
Hi Samuel,

Thank you for your long time support.
I know what i have to do.Thank you very much!

Best Regards