掲示板

Date type in Structure

thumbnail
13年前 に Kishor Ghule によって更新されました。

Date type in Structure

New Member 投稿: 13 参加年月日: 10/06/19 最新の投稿
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
thumbnail
13年前 に Piotr Filipowicz によって更新されました。

RE: Date type in Structure

Junior Member 投稿: 52 参加年月日: 10/11/18 最新の投稿
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
thumbnail
12年前 に David García González によって更新されました。

RE: Date type in Structure

Regular Member 投稿: 127 参加年月日: 09/07/14 最新の投稿
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.

<dynamic-element name="Peso" type="list" index-type="" repeatable="false"></dynamic-element>


Where is it explained? Is there a dtd?

Thanks!
thumbnail
12年前 に David García González によって更新されました。

RE: Date type in Structure

Regular Member 投稿: 127 参加年月日: 09/07/14 最新の投稿
I found it in another 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
thumbnail
13年前 に Piotr Filipowicz によって更新されました。

RE: Date type in Structure

Junior Member 投稿: 52 参加年月日: 10/11/18 最新の投稿
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.
thumbnail
13年前 に Kishor Ghule によって更新されました。

RE: Date type in Structure

New Member 投稿: 13 参加年月日: 10/06/19 最新の投稿
Hi Piotr,

Thanks! I'll go through the tutorial.
11年前 に Simon Marcini によって更新されました。

RE: Date type in Structure

New Member 投稿: 18 参加年月日: 12/02/13 最新の投稿
Piotr 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?
thumbnail
11年前 に Javi GC によって更新されました。

RE: Date type in Structure

New Member 投稿: 4 参加年月日: 12/08/16 最新の投稿
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
10年前 に Asier Hernández によって更新されました。

RE: Date type in Structure

New Member 投稿: 24 参加年月日: 11/02/01 最新の投稿
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!
10年前 に Beatriz Sánchez Pérez によって更新されました。

RE: Date type in Structure

New Member 投稿: 24 参加年月日: 11/04/28 最新の投稿
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>
thumbnail
9年前 に Sergio Romero Zayas によって更新されました。

RE: Date type in Structure

Regular Member 投稿: 151 参加年月日: 08/04/14 最新の投稿
Missing some important steps:
add to main.js:
registerFieldModel('Date', 'date', 'DateField', true);


code of edit_article_content_xsd_date_el.jspf.


<aui:fieldset>
&lt;%
Calendar cal = CalendarFactoryUtil.getCalendar(timeZone, locale);
if (elContent != null &amp;&amp; !elContent.equals("")) {
  DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd H:m");
  Date date = (Date)formatter.parse(elContent);
  cal.setTime(date);
}

%&gt;

<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 %>" />

    &nbsp;

    <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 &lt; 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 &amp;&amp; !isNaN(hour)) {
			hour = hour + 12;
		}

		if (month &lt; 10) {
			month = '0' + month;
		}
		if (day &lt; 10) {
			day = '0' + day;
		}
		if (hour &lt; 10) {
			hour = '0' + hour;
		}
		if (minute &lt; 10) {
			minute = '0' + minute;
		}
		if (second &lt; 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.
emoticon
9年前 に Haythem Benizid によって更新されました。

RE: Date type in Structure

New Member 投稿: 7 参加年月日: 14/08/03 最新の投稿
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 emoticon
thumbnail
9年前 に Sergio Romero によって更新されました。

RE: Date type in Structure

Regular Member 投稿: 151 参加年月日: 08/04/14 最新の投稿
You should use velocity. The velocity template you can do this.