Fórum
Date type in Structure
Kishor Ghule, modificado 13 Anos atrás.
Date type in Structure
New Member Postagens: 13 Data de Entrada: 19/06/10 Postagens Recentes
I want to add Date type in the input field of Structure. By default there is no such provision by Liferay. I have following questions for this:
1) How can i achieve this?
2) Where can i do development for this?
3)Which file is responsible for the input field types that we see when we click Add Row while creating a Structure
1) How can i achieve this?
2) Where can i do development for this?
3)Which file is responsible for the input field types that we see when we click Add Row while creating a Structure
Piotr Filipowicz, modificado 13 Anos atrás.
RE: Date type in Structure
Junior Member Postagens: 52 Data de Entrada: 18/11/10 Postagens Recentes
Hi Kishor!
This post is only suggest where you find pieces of code which are responsible for render and edit structure's field.
- html/portlet/journal/js/main.js file. In this file we register new field's model: registerFieldModel(namespace, type, variableName, optionsEditable) and add this one to model's map in function _fieldInstanceFactory() : <type> : Journal.FieldModel.<namespace>
- html/portlet/journal/edit_article_content_xsd_el.jsp file. We display and serve our new type inside <div> tag (journal-article-component-container).
- html/portlet/journal/edit_structure_xsd_el.jsp file. We shoud add our new type to select list: <select id="<portlet:namespace />structure_el<%= count.getValue() %>_type" tabindex="<%= tabIndex.getValue() %>">
- html/portlet/journal/edit_article_structure extra.jspf file. We add our type to select list: (add our type to select fieldType inside journalArticleEditField's field). We also define look out field inside journalFieldModelContainer's div (create div with attribute dataType="<type>").
- In file html/portlet/journal/edit_article_extra.jsp we must add and register our new component.
Hints:
You must look and handle your new component in this files:
- html/portlet/journal/js/main.js
- html/portlet/journal/edit_article_content_xsd_el.jsp
- portal-impl/src/com/liferay/portlet/journal/action/EditArticleAction.java
This post is only suggest where you find pieces of code which are responsible for render and edit structure's field.
- html/portlet/journal/js/main.js file. In this file we register new field's model: registerFieldModel(namespace, type, variableName, optionsEditable) and add this one to model's map in function _fieldInstanceFactory() : <type> : Journal.FieldModel.<namespace>
- html/portlet/journal/edit_article_content_xsd_el.jsp file. We display and serve our new type inside <div> tag (journal-article-component-container).
- html/portlet/journal/edit_structure_xsd_el.jsp file. We shoud add our new type to select list: <select id="<portlet:namespace />structure_el<%= count.getValue() %>_type" tabindex="<%= tabIndex.getValue() %>">
- html/portlet/journal/edit_article_structure extra.jspf file. We add our type to select list: (add our type to select fieldType inside journalArticleEditField's field). We also define look out field inside journalFieldModelContainer's div (create div with attribute dataType="<type>").
- In file html/portlet/journal/edit_article_extra.jsp we must add and register our new component.
Hints:
You must look and handle your new component in this files:
- html/portlet/journal/js/main.js
- html/portlet/journal/edit_article_content_xsd_el.jsp
- portal-impl/src/com/liferay/portlet/journal/action/EditArticleAction.java
David García González, modificado 12 Anos atrás.
RE: Date type in Structure
Regular Member Postagens: 127 Data de Entrada: 14/07/09 Postagens Recentes
I wanted to configure a new element of type list (combo box select) but I dont know how to configure the values of this combo.
Where is it explained? Is there a dtd?
Thanks!
<dynamic-element name="Peso" type="list" index-type="" repeatable="false"></dynamic-element>
Where is it explained? Is there a dtd?
Thanks!
David García González, modificado 12 Anos atrás.
RE: Date type in Structure
Regular Member Postagens: 127 Data de Entrada: 14/07/09 Postagens Recentes
I found it in another forum:
Forum
<dynamic-element name="Peso" type="list" index-type="" repeatable="false">
<dynamic-element name="extinct" type="Extinct" index-type="" repeatable="false"> </dynamic-element>
<dynamic-element name="extinctWild" type="Extinct%20in%20the%20wild" index-type="" repeatable="false"> </dynamic-element>
<dynamic-element name="criticEndanger" type="Critically%20Endangered" index-type="" repeatable="false"> </dynamic-element>
<dynamic-element name="endanger" type="Endangered" index-type="" repeatable="false"> </dynamic-element>
<dynamic-element name="vulnerable" type="Vulnerable" index-type="" repeatable="false"></dynamic-element>
</dynamic-element>
Forum
Piotr Filipowicz, modificado 13 Anos atrás.
RE: Date type in Structure
Junior Member Postagens: 52 Data de Entrada: 18/11/10 Postagens Recentes
Hi!
I wrote tutorial about creating new structure's fields. This tutorial shows how to add date type in structure. Please, visit liferaycms.wordpress.com.
I wrote tutorial about creating new structure's fields. This tutorial shows how to add date type in structure. Please, visit liferaycms.wordpress.com.
Kishor Ghule, modificado 13 Anos atrás.
RE: Date type in Structure
New Member Postagens: 13 Data de Entrada: 19/06/10 Postagens Recentes
Hi Piotr,
Thanks! I'll go through the tutorial.
Thanks! I'll go through the tutorial.
Simon Marcini, modificado 11 Anos atrás.
RE: Date type in Structure
New Member Postagens: 18 Data de Entrada: 13/02/12 Postagens RecentesPiotr Filipowicz:
Hi!
I wrote tutorial about creating new structure's fields. This tutorial shows how to add date type in structure. Please, visit liferaycms.wordpress.com.
Hey Piotr!
I've followed your tutorial, it's really good. Thanks. However, I'm trying to add empty field to dropdownlist. I actually want the user to be able to choose empty value from the calender: empty day, month and year, but I'm having some troubles figuring it out. Could you help me with that please?
Javi GC, modificado 11 Anos atrás.
RE: Date type in Structure
New Member Postagens: 4 Data de Entrada: 16/08/12 Postagens Recentes
Hi Piotr,
Is it a solution available for the calendar? Selection on it doesn't change any value (year, month or day).
I'm using CE 6.1.1 CE GA2.
Thanks in advance
Is it a solution available for the calendar? Selection on it doesn't change any value (year, month or day).
I'm using CE 6.1.1 CE GA2.
Thanks in advance
Asier Hernández, modificado 10 Anos atrás.
RE: Date type in Structure
New Member Postagens: 24 Data de Entrada: 01/02/11 Postagens Recentes
I am looking for this hook too. The hook presented in http://liferaycms.wordpress.com/2011/01/15/add-new-structure-field/ is not working for Liferay 6.1.
¿Some ideas?
Thanks a lot!
¿Some ideas?
Thanks a lot!
Beatriz Sánchez Pérez, modificado 10 Anos atrás.
RE: Date type in Structure
New Member Postagens: 24 Data de Entrada: 28/04/11 Postagens Recentes
This is the code for liferay 6.1.1 GA2
1.- in main.js add
var model = {
'boolean': Journal.FieldModel.Boolean,
'document_library': Journal.FieldModel.DocumentLibrary,
'image': Journal.FieldModel.Image,
'link_to_layout': Journal.FieldModel.LinkToPage,
'list': Journal.FieldModel.List,
'multi-list': Journal.FieldModel.MultiList,
'selection_break': Journal.FieldModel.SelectionBreak,
'text': Journal.FieldModel.Text,
'text_area': Journal.FieldModel.TextArea,
'text_box': Journal.FieldModel.TextBox,
'date': Journal.FieldModel.Date,
2.- edit_article_content_xsd_el.jsp
<c:if test='<%= elType.equals("date") %>'>
<%@ include file="/html/portlet/journal/edit_article_content_xsd_date_el.jspf" %>
</c:if>
3.- edit_article_extra.jspf
<div dataType="date">
<liferay-ui:message key="date" />
</div>
4.- edit_article_structure_extra.jspf
<aui:select disabled="<%= true %>" name="fieldType">
<aui:option label="text-field" value="text" />
<aui:option label="text-box" value="text_box" />
<aui:option label="text-area" value="text_area" />
<aui:option label="checkbox" value="boolean" />
<aui:option label="options" />
<aui:option label="select-box" value="list" />
<aui:option label="multi-selection-list" value="multi-list" />
<aui:option label="image-uploader" value="image" />
<aui:option label="document-library" value="document_library" />
<aui:option label="link-to-page" value="link_to_layout" />
<aui:option label="selection-break" value="selection_break" />
<aui:option label="date" value="date" />
5.- edit_structure_xsd_el.jsp
<option <%= elType.equals("date") ? "selected" : "" %> value="date"><liferay-ui:message key="date" /></option>
1.- in main.js add
var model = {
'boolean': Journal.FieldModel.Boolean,
'document_library': Journal.FieldModel.DocumentLibrary,
'image': Journal.FieldModel.Image,
'link_to_layout': Journal.FieldModel.LinkToPage,
'list': Journal.FieldModel.List,
'multi-list': Journal.FieldModel.MultiList,
'selection_break': Journal.FieldModel.SelectionBreak,
'text': Journal.FieldModel.Text,
'text_area': Journal.FieldModel.TextArea,
'text_box': Journal.FieldModel.TextBox,
'date': Journal.FieldModel.Date,
2.- edit_article_content_xsd_el.jsp
<c:if test='<%= elType.equals("date") %>'>
<%@ include file="/html/portlet/journal/edit_article_content_xsd_date_el.jspf" %>
</c:if>
3.- edit_article_extra.jspf
<div dataType="date">
<liferay-ui:message key="date" />
</div>
4.- edit_article_structure_extra.jspf
<aui:select disabled="<%= true %>" name="fieldType">
<aui:option label="text-field" value="text" />
<aui:option label="text-box" value="text_box" />
<aui:option label="text-area" value="text_area" />
<aui:option label="checkbox" value="boolean" />
<aui:option label="options" />
<aui:option label="select-box" value="list" />
<aui:option label="multi-selection-list" value="multi-list" />
<aui:option label="image-uploader" value="image" />
<aui:option label="document-library" value="document_library" />
<aui:option label="link-to-page" value="link_to_layout" />
<aui:option label="selection-break" value="selection_break" />
<aui:option label="date" value="date" />
5.- edit_structure_xsd_el.jsp
<option <%= elType.equals("date") ? "selected" : "" %> value="date"><liferay-ui:message key="date" /></option>
Sergio Romero Zayas, modificado 9 Anos atrás.
RE: Date type in Structure
Regular Member Postagens: 151 Data de Entrada: 14/04/08 Postagens Recentes
Missing some important steps:
add to main.js:
code of edit_article_content_xsd_date_el.jspf.
add to if in main.js
Also we must define the "getDateAsString” function
Everything said in this blog perfectly : http://liferaycms.wordpress.com/2011/01/15/add-new-structure-field/
Thanks to its creator.
Happy Friday and happy weekend.
add to main.js:
registerFieldModel('Date', 'date', 'DateField', true);
code of edit_article_content_xsd_date_el.jspf.
<aui:fieldset>
<%
Calendar cal = CalendarFactoryUtil.getCalendar(timeZone, locale);
if (elContent != null && !elContent.equals("")) {
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd H:m");
Date date = (Date)formatter.parse(elContent);
cal.setTime(date);
}
%>
<aui:field-wrapper>
<div>
<liferay-ui:input-date dayParam="dateDay" dayValue="<%= cal.get(Calendar.DATE) %>" disabled="<%= false %>" firstDayOfWeek="<%= cal.getFirstDayOfWeek() - 1 %>" monthParam="dateMonth" monthValue="<%= cal.get(Calendar.MONTH) %>" yearParam="dateYear" yearValue="<%= cal.get(Calendar.YEAR) %>" yearRangeStart="<%= cal.get(Calendar.YEAR) %>" yearRangeEnd="<%= cal.get(Calendar.YEAR) + 5 %>" />
<liferay-ui:input-time amPmParam="dateAmPm" amPmValue="<%= cal.get(Calendar.AM_PM) %>" hourParam="dateHour" hourValue="<%= cal.get(Calendar.HOUR) %>" minuteParam="dateMinute" minuteValue="<%= cal.get(Calendar.MINUTE) %>" minuteInterval="<%= 1 %>" />
</div>
</aui:field-wrapper>
</aui:fieldset>
add to if in main.js
if (type == 'date') {
var dateContents = componentContainer.all('select');
var date = [Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN, Number.NaN];
if (dateContents) {
dateContents.each(
function(select, selectIndex, selects) {
var options = select.all('option');
if (options) {
options.each(
function(option, optionIndex, options) {
if (option.get('selected')) {
//name selecta, zawierajacego wybrany item
var selectName = select.get('name');
var selectedValue = option.val();
if (selectName.match(/dateDay$/)) {
date[0] = selectedValue;
} else if (selectName.match(/dateMonth$/)) {
date[1] = selectedValue;
} else if (selectName.match(/dateYear$/)) {
date[2] = selectedValue;
} else if (selectName.match(/dateHour$/)) {
date[3] = selectedValue;
} else if (selectName.match(/dateMinute$/)) {
date[4] = selectedValue;
} else if (selectName.match(/dateAmPm$/)) {
date[6] = selectedValue;
}
}
},
select
);
}
}
);
}
content = instance.getDateAsString(date);
}
Also we must define the "getDateAsString” function
getDateAsString: function(stringDateArray) {
if (stringDateArray.length != 7) {
return '';
}
var intDateArray = new Array(stringDateArray.length);
var notNaNExist = false;
for (var i = 0; i < stringDateArray.length; i++) {
intDateArray[i] = parseInt(stringDateArray[i], 10);
if (intDateArray[i] != NaN) {
notNaNExist = true;
}
}
if (!notNaNExist) {
return '';
}
var day = intDateArray[0];
var month = intDateArray[1];
var year = intDateArray[2];
var hour = intDateArray[3];
var minute = intDateArray[4];
var second = 0;
var ampm = intDateArray[6];
if (!isNaN(month)) {
month = month + 1;
}
if (ampm == 1 && !isNaN(hour)) {
hour = hour + 12;
}
if (month < 10) {
month = '0' + month;
}
if (day < 10) {
day = '0' + day;
}
if (hour < 10) {
hour = '0' + hour;
}
if (minute < 10) {
minute = '0' + minute;
}
if (second < 10) {
second = '0' + second;
}
return year + '-' + month + '-' + day + ' ' + hour + ':' + minute;
}
Everything said in this blog perfectly : http://liferaycms.wordpress.com/2011/01/15/add-new-structure-field/
Thanks to its creator.
Happy Friday and happy weekend.
Haythem Benizid, modificado 9 Anos atrás.
RE: Date type in Structure
New Member Postagens: 7 Data de Entrada: 03/08/14 Postagens Recentes
Hello,
I work with Liferay 6.2 CE.
I added a new structure, in which I added a date field. when adding content I can not specify the time.
how I can configure the field the way it gives me the possibilty to enter the date and time ?
should i add a new field?
PLZ help
I work with Liferay 6.2 CE.
I added a new structure, in which I added a date field. when adding content I can not specify the time.
how I can configure the field the way it gives me the possibilty to enter the date and time ?
should i add a new field?
PLZ help
Sergio Romero, modificado 9 Anos atrás.
RE: Date type in Structure
Regular Member Postagens: 151 Data de Entrada: 14/04/08 Postagens Recentes
You should use velocity. The velocity template you can do this.