You often need web content for different purposes on a project. Reusing the same content over and over can introduce subtle bugs, and creating new content can be painful and time-consuming. For instance, you may need sample web content to test the look and feel of a website. In this scenario you don’t need a large amount of content, but you need variety. On the other hand, if you are testing modifications to Liferay’s search portlet, you may need a lot of content.
To address these needs, the Auto Content Populate Portlet creates Liferay web content from random Wikipedia articles. The portlet allows you to enter the number of articles you wish to create. Since the content is random and may be required just for testing, a delete button makes it easy to remove the content you created.
The portlet works on Liferay 6.2 EE and CE. Download the portlet from the Liferay Marketplace and deploy. Once deployment is complete you can go ahead and add the portlet to a page. The portlet can be found within the XTIVIA applications category and does not require any configuration. Below is a screenshot of the portlet when it is placed on a page:
Create Web Content
The Number of Articles text field allows you to enter the number of web content articles to create. Once you click the Create button, the creation of articles starts and the page looks as follows:
Delete Web Content
Clicking the Delete button removes all the web content created by that portlet instance. For simplicity’s sake, the ids of the created web content are kept within the portlet preferences of a given instance. When the Delete button is clicked, these ids are retrieved from the portlet preferences and deleted. The caveat to this implementation is that the portlet preferences must not be cleared before the Delete button is clicked. That is, if you remove the portlet from the page or clear the portlet preferences, clicking the Delete button will have no effect. You’ll have to find and delete the content on your own through the Control Panel.
Verify Content Creation
You can view the list of created web content by going to the Content section of Site Administration. Under the Content section click on Web Content. A list of created web content will show up as in the screenshot below:
MySQL Encoding Issue
The portlet works without errors when using HSQLDB, but MySQL may have some encoding issues. The web content may not be created if the charset of the content and title columns of the journalarticle table is not utf-8 or utf8mb4. If your MySQL database does not use a charset like utf-8 as a default, run the script below to make the modification:
ALTER TABLE [db_schema].journalarticle MODIFY COLUMN content LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
ALTER TABLE [db_schema].journalarticle MODIFY COLUMN title LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Visit the Liferay Marketplace to download.