Set Max Char to Content
- Liferay Portal 6.1 CE GA2+
- Liferay Portal 6.1 EE GA2+
In most of the cases, web contents are created with the help of structure and template. While creating web content with structure and template, we can't restrict user to enter data with specific length. In other word, out of the box, there is no such facility to restrict user to enter predefined number of characters for structure element. This app facilitate this feature.
This app is comprises of one hook. After deploying this app, if we want to restrict user to add specific length of data then we need to set number of allowed characters in meta data (called 'noOfCharacterAllowed') of structur's element.
For example, let say there is one element in structure called 'component' and we want to set number of allowed characters to 100, then defined it in meta data as below
<dynamic-element name="component" type="text" index-type="" repeatable="false">
After defining number of allowed character in meta data, label like "Maximum 100 Characters are allowed" will be visible after each such element on web content creation screen. When user tries to save / publish web content, JS error message will be displayed for each such element where user had entered more than allowed characters.
This way we can restrict number of allowed character dynamically and it is configurable through meta data.
Currently this feature is available to following types of elements
For element of type Text-Area(HTML), the data will be stored in form of HTML. The No of character will be counted after filtering all html tags by this element, so it will count no of character which is actually entered by user.