In other words, Which Database tables do i need to look into for the mapping of a portlet to a page in an organization? If there is such a thing?! We are using Liferay 6.1.20
Apart from the marketplace portlet.
If you have access to the Database you can fire a simple query on the Layout
table to know in what all pages your portlet is added:
SELECT * FROM Layout WHERE typeSettings LIKE '%my_WAR_myportlet%';
Also you can build a FinderImpl with service-builder to execute this query through a portlet and add that portlet to page to display in whatever format you want.
Below is another solution without deploying any portlet and without having access to the DB (tested on MySQL DB):
Beanshell
from the Language drop-downPaste the following script code in the textarea and press the button execute:
import com.liferay.portal.kernel.dao.jdbc.DataAccess;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.StringBundler;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = DataAccess.getUpgradeOptimizedConnection();
// your custom query here
String sqlQuery = "SELECT * FROM Layout WHERE typeSettings LIKE '%my_WAR_myportlet%'";
out.println("SQL Query: "+ sqlQuery);
ps = con.prepareStatement(sqlQuery);
rs = ps.executeQuery();
ResultSetMetaData rsmd = rs.getMetaData();
int columnCount = rsmd.getColumnCount();
List rows = new ArrayList();
List columnLabels = new ArrayList();
columnLabels.add("Sr. No.");
for (int c = 1; c <= columnCount; c++) {
String cl = rsmd.getColumnLabel(c);
columnLabels.add(cl);
}
while (rs.next()) {
List row = new ArrayList(columnCount);
for (int c = 1; c <= columnCount; c++) {
Object value = rs.getObject(c);
row.add(value);
}
rows.add(row);
}
// --- formatting the results ---
out.append("<div class=\"lfr-search-container \"><div class=\"results-grid\">");
out.append("<table class=\"taglib-search-iterator\">");
out.append("<thead>");
out.append("<tr class=\"portlet-section-header results-header\">");
for (String value : columnLabels) {
out.append("<th>");
out.append(value);
out.append("</th>");
}
out.append("</tr>");
out.append("</thead>");
out.append("<tbody>");
boolean alt = false;
long resultsCount = 1;
for (List line : rows) {
out.append("<tr class=\"portlet-section-alternate results-row " + (alt ? "alt" : "") + "\">");
// for sr. no.
out.append("<td>");
out.append(resultsCount + "");
out.append("</td>");
resultsCount = resultsCount + 1;
for (Iterator iterator = line.iterator(); iterator.hasNext();) {
Object value = (Object) iterator.next();
out.append("<td>");
if (value != null) {
out.append(value.toString());
} else {
out.append("<span style=\"font-style:italic\">null</span>");
}
out.append("</td>");
}
out.append("</tr>");
alt = !alt;
}
out.append("</tbody>");
out.append("</table>");
out.append("</div></div>");
} catch (Exception exp) {
out.println("ERROR: " + exp);
throw exp;
}
finally {
DataAccess.cleanUp(con, ps, rs);
}
Please remember to change the string my_WAR_myportlet
to your portletId
String sqlQuery
.Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With