掲示板

Hide metadata in DDMStructure

9年前 に Giacomo Castellini によって更新されました。

Hide metadata in DDMStructure

New Member 投稿: 21 参加年月日: 14/06/26 最新の投稿
I am using the following tag to show the metadata's

<liferay-ddm:html
classNameId="<%= PortalUtil.getClassNameId(DDMStructure.class) %>"
classPK="<%= ddmStructure.getPrimaryKey() %>"
fields="<%= fields %>"
fieldsNamespace="<%= String.valueOf(ddmStructure.getPrimaryKey()) %>"
requestedLocale="<%= locale %>"
/>

Is it possibile to hide some metadatas?
Thanks for the reply
Giacomo
thumbnail
9年前 に Sandip Patel によって更新されました。

RE: Hide metadata in DDMStructure

Regular Member 投稿: 205 参加年月日: 11/01/05 最新の投稿
Hi,

Hope below link may help you...

https://www.liferay.com/community/wiki/-/wiki/Main/Dynamic+Data+Mapping+-+Field+Types+Customization

Regards,
Sandip Patel
9年前 に Giacomo Castellini によって更新されました。

RE: Hide metadata in DDMStructure

New Member 投稿: 21 参加年月日: 14/06/26 最新の投稿
Thanks Sandip
for the reply but I need to do it dynamically (I mean hiding or showing)..
thumbnail
8年前 に Marco Azzalini によって更新されました。

RE: Hide metadata in DDMStructure

Regular Member 投稿: 146 参加年月日: 14/11/18 最新の投稿
Giorgio Gosti:
Thanks Sandip
for the reply but I need to do it dynamically (I mean hiding or showing)..


Hi Giorgio, I am facing with very similar problem, enable/disable metadata fields or, in general, control how they are rendered in jsp page.
Unfortunately the taglib <liferay-ddm:html> does not offer any way to control it
Did you find any solution or workaround? My enviroment is Liferay 6.2 GA3

Thanks in advance,

Marco Azzalini
8年前 に Giorgio Gosti によって更新されました。

RE: Hide metadata in DDMStructure

New Member 投稿: 21 参加年月日: 14/06/26 最新の投稿
Hi Marco
unfortunately there is not way to control the tag <liferay-ddm:html>.
The only solution/workaround that I found was to manually modify the Htlm code once the page is loaded

<script>

$(document).ready(function(){
....
}

</script>
thumbnail
8年前 に Marco Azzalini によって更新されました。

RE: Hide metadata in DDMStructure

Regular Member 投稿: 146 参加年月日: 14/11/18 最新の投稿
Giorgio Gosti:
Hi Marco
unfortunately there is not way to control the tag <liferay-ddm:html>.
The only solution/workaround that I found was to manually modify the Htlm code once the page is loaded

<script>

$(document).ready(function(){
....
}

</script>

Hi Giorgio, I just discovered a workaround, for my scenario at least, where I have only 15 metadata.
In the liferay-ddm taglib there is another tag called 'html-field'. So I removed the <liferay-ddm:html> tag and used some <liferay-ddm:html-field> where I can use the readOnly attribute to control dinamically if the field has to be rendered as editable or not.
The interesting thing is that this tag is used only once through all portal's JSP pages (!), in the
select_structure_field.jsp
:

<liferay-ddm:html-field classNameId="<%= PortalUtil.getClassNameId(DDMStructure.class) %>" classPK="<%= ddmStructureId %>" field="<%= ddmField %>" fieldsNamespace="<%= fieldsNamespace %>" />

Another advantage is that I can also control the layout of my custom metadata fields, because the Liferay standard (one below other) is, honestly, awful !
Of course, putting the tag inside a <c:if> tag you can also get the visibility (or not) of a field based on your business logic.

I hope this can be of help to someone, anyway, I am also interested in your javascript solution... could you give me some more details?

ciao
Marco
8年前 に Giorgio Gosti によって更新されました。

RE: Hide metadata in DDMStructure

New Member 投稿: 21 参加年月日: 14/06/26 最新の投稿
Hi Marco
thanks for sharing the solution.
For what concern my part I did the following:
Since that the <div> surronding the data created by tag <liferay-ddm:html>. are identified with data-fieldname:

<div id="yui_patched_v3_11_0_1_1439391656171_280" class="control-group field-wrapper" data-repeatable="false" data-fieldnamespace="_INSTANCE_axfo"

data-fieldname="comments">

I looked in the html code for data-fieldname = "field to hide" and put style.display = 'none'.
In the following piece of code hiddenFields is a String with the list (separated by comma) of field-name values that I wanted to hide


$(document).ready(function(){
if(document.getElementById("<portlet:namespace/>ddmStructureId") != null){
var ddmStructureId= document.getElementById("<portlet:namespace/>ddmStructureId").value;
var formDDMTemplateId= document.getElementById("<portlet:namespace/>formDDMTemplateId").value;

var hiddenFields = document.getElementById("<portlet:namespace/>hiddenFields").value;

var inputs2 = hiddenFields.split(",");

if(inputs2 != ""){
for (var i = 0; i < inputs2.length; i++) {
if(document.querySelector('[data-fieldname*=' + inputs2 + ']') != null){
document.querySelector('[data-fieldname*=' + inputs2 + ']').style.display = 'none';
}

}
}
}
});


ciao Giorgio