Following are the steps to achieve this functionality:
- In our weather portlet, we can provide a plugin code generation screen, where the user can set the parameters and based on that, the portlet will generate code snippet.
- Once the user submits the configuration form, we store the configuration values in database and generate unique id (UUID) of this record.
- We can add the unique id in Liferay’s code snippet as a request parameter of URL. The code snippet would look something like this:
<script src=”http://localhost:8080/o/frontend-js-web/liferay/widget.js” type=”text/javascript”></script> <script type=”text/javascript”>Liferay.Widget({url: ‘http://localhost:8080/widget/web/guest/weather -widget/-/com_azilen_weather_web_portlet_WeatherPortlet?cfg= a82286b5-5df1-6825-f9df-56f5dcb72c04’}); </script>
- Users will grab this snippet and add to the desired webpage(s) of their websites.
- In the portlet’s render phase, you can get the “cfg” parameter. Get the configuration record based on that UUID.
- Render the portlet based on the configuration saved by user.
- This way all users will be able to configure and include the weather portlet in their own websites.
If you still have any query regarding how to enable widget integration for Liferay Application, you can discuss with our Liferay consultant! or send your query to info@azilen.com