Fórumok

Is there any way to hide the input field of Tags of message board portlet?

thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

Is there any way to hide the input field of Tags of message board portlet?

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hi everyone,

When posting a new thread, is there any way to hide the input field of <aui:input name="Tags" type="assetTags"/> or preventing users from inputting tags by selecting tag from the button "Select" but cannot use the input field.

(This <aui:input name="Tags" type="assetTags"/> can be found in line 308 of edit_message.jsp of message board portlet).

Regards,
Quang
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
We can not do this using any configuration of the message board portlet. We have to customize the code using Hook, and comment that line.

Or you can also hide that using css (display:none) on the specific page. (Page Level CSS) But this approach is not advisable, it will still load on the page, by css we are hiding it. for time being we can do that

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hiral Ramavat:
We can not do this using any configuration of the message board portlet. We have to customize the code using Hook, and comment that line.

Or you can also hide that using css (display:none) on the specific page. (Page Level CSS) But this approach is not advisable, it will still load on the page, by css we are hiding it. for time being we can do that

Thanks,
Hiral


Thank you for your quick reply. Yeah, I already used hook to comment that line but I still don't know how to get the tags from database and stick it with the post message after pressing publish button... emoticon it seems like a miracle emoticon I have been searching for it since 3 weeks ago.
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
Are you searching specific tag from the database?

If so, you can use API provided by Liferay to get the tags. Let me know if you need any help on this. Which version of liferay you are using?

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hi Hiral Ramavat,

I just want to display all the tags which in the database to the jsp page by using AJAX and to stick it with the message. I'm using Liferay version 6.0.6 CE.

P/S: Just like the "Select" button below the input field of Tags

Thanks,
Quang
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
If you want to display all the tag from all the community/organization then you can use following API provided by Liferay.

List<com.liferay.portlet.tags.model.TagsEntry> results = TagsEntryLocalServiceUtil.getEntries();

Above will give you all the tag in list format.

Hope it will help you.

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hiral Ramavat:
If you want to display all the tag from all the community/organization then you can use following API provided by Liferay.

List<com.liferay.portlet.tags.model.TagsEntry> results = TagsEntryLocalServiceUtil.getEntries();

Above will give you all the tag in list format.

Hope it will help you.

Thanks,
Hiral


Hi Hiral,

Your code doesn't work for my liferay 6.0.6. Anyway, thank you so much for your reply!
I already tried to get the tags from database by the idea you provided but the problem is how can I make it tagged to the message. For example, if I post a thread with title "Liferay", content: "Liferay" and I check two tags: "7cogs" and "Liferay", so how do my thread "Liferay" got tagged with "7cogs" and "Liferay" ?

Regards,
Quang
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
Are you using Liferay OOB feature for tagging your content? Or have you completely disabled it?
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
I didn't know about Liferay OOB feature about tagging content in Message Board porlet. In addition, I googled it but can't figure out what it is. I would appreciate if you could help me!!
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
You can use tagging feature provided by liferay.

Try to add new thread in the message board portlet. It will allow you to add or select the tag for that thread.

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hi Hiral,

According to my first post, I did know it but.... what I expected is to prevent users from inputting new tags from the input field of <aui:input>, therefore, they can only select which tags they want to tagged their thread.

Regards,
Quang
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
Ohh...Ok...but in you previous post you have written that you want tagging your content in message.

can you please elaborate more about your problem

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Hi Hiral,

First of all, my problem is I want to forbid the insert tags function, I mean I don't want any users can create new tags except Admin. Therefore, when I choose "Post New Thread" in message board portlet, it should only display for users a list of tags from database to select, not to insert their new tags. However, I already made all the tags display in posting message page but how do I tag my message by selecting tags from the tag list ? You got me?

Anyway, thanks for your concern!!
Regards,
Quang
Hiral Ramavat, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Regular Member Bejegyzések: 103 Csatlakozás dátuma: 2012.02.13. Legújabb bejegyzések
You mean, it is not allow you to select the particular tag with that past? Have you hide select button provided by liferay and using your own custom List of tags? Is it so? - Please Confirm.

Thanks,
Hiral
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
This is the default tags in message board portlet in "posting or editting message" page.



I want to remove or hide the input field, and only display the select button to make this box appears:



Users can only select tags, but not to input new tags.
thumbnail
Rochad Tlusty, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Junior Member Bejegyzések: 42 Csatlakozás dátuma: 2012.01.18. Legújabb bejegyzések
I think I might be able to help. In your instance of Liferay, you should have a folder /html/js/liferay, There you will find a file named asset_tags_selector.js (if you can't find it just search for the file). Around line 398 of this file you will see the following code,



                                        _onAddEntryClick: function(event) {
                                                var instance = this;

                                                var text = instance.inputNode.val();

                                                if (text) {
                                                        if(text.indexOf(',') &gt; -1) {
                                                                var items = text.split(',');

                                                                A.each(
                                                                        items,
                                                                        function(item, index, collection) {
                                                                                instance.entries.add(item, {});
                                                                        }
                                                                );
                                                        } else {
                                                                instance.entries.add(text, {});
                                                        }
                                                }

                                                Liferay.Util.focusFormField(instance.inputNode);
                                        }

Here you can modify or remove the ability to add tags through the asset selector. As far as being able to type in tags, I think you can just change the line around 115 in this file to false,

allowAnyEntry: {
                                                value: true
                                        },



Maybe not exactly what you're looking for, but should help you get closer.
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
It helps me a lot. I will try.

Thanks for your help !
thumbnail
Rochad Tlusty, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl

Junior Member Bejegyzések: 42 Csatlakozás dátuma: 2012.01.18. Legújabb bejegyzések
I should also add that you probably want to remove the suggestions as well, as it can create new tags based on keywords in the body (probably undesirable for you).
thumbnail
Quang Tran Minh, módosítva 11 év-val korábban

RE: Is there any way to hide the input field of Tags of message board portl (Válasz)

New Member Bejegyzések: 11 Csatlakozás dátuma: 2012.05.02. Legújabb bejegyzések
Rochad Tlusty:
I should also add that you probably want to remove the suggestions as well, as it can create new tags based on keywords in the body (probably undesirable for you).



After taking my final exams, I found a solution for my problem.
First step: we need to look at all the files in message_boards portlet folder, then the code to create "insert tags" function is in line 308 of edit_message.jsp
<aui:input name="tags" type="assetTags" />

Our brain may raise a question: "How does this thing work? I do not understand.". For more understanding, we need to break down the tag a little into its separate parts:
_ aui
                 _ input
                 _ assetTags

Next step: These things are liferay params, so where are they? Let's look at this path:
  tomcat-server\webapps\ROOT\WEB-INF\tld\liferay-ui.tld

In this file (liferay-ui.tld), we search for anything related to assetTags. After looking that file, we will see these lines
 <tag>
		<name>asset-tags-selector</name>
		<tag-class>com.liferay.taglib.ui.AssetTagsSelectorTag</tag-class>
		<body-content>JSP</body-content>
		<attribute>
			<name>className</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>classPK</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>contentCallback</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>curTags</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>focus</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
		<attribute>
			<name>hiddenInput</name>
			<required>false</required>
			<rtexprvalue>true</rtexprvalue>
		</attribute>
	</tag>

This is what we are looking for. To find the path to the JSP, its stored in the tagclass.
 <tag-class>com.liferay.taglib.ui.AssetTagsSelectorTag</tag-class>

In the java class, you'll see a variable with the path to the JSP:
 private static final String _PAGE = "/html/taglib/ui/asset_tags_selector/page.jsp";

In the JSP file (page.jsp), there is a div:
<div class="lfr-tags-selector-content" id="<%= namespace + randomNamespace %>assetTagsSelector">
	<aui:input name="<%= hiddenInput %>" type="hidden" />

	<input class="lfr-tag-selector-input" id="<%= randomNamespace %>assetTagNames" size="15" type="text">
</div>


All we need is to add the attribute disabled="disabled" to the input tag in order to prevent any input from users.
After that, to remove "Add" button with "plus" icon, lets look at
\html\js\liferay\asset_tags_selector.js

Take a deeper look at line 398 to line 439:

var toolbar = [
							/*{
								handler: {
									context: instance,
									fn: instance._onAddEntryClick
								},
								icon: 'plus',
								id: 'add',
								label: Liferay.Language.get('add')
							},*/
							{
								handler: {
									context: instance,
									fn: instance._showSelectPopup
								},
								icon: 'search',
								id: 'select',
								label: Liferay.Language.get('select')
							}
						];

The variable toolbar stores 3 buttons, which are add, select and suggestions, all we need is put a comment block to "add" codes like the code above.
We finish here.