The requirement is as follows,
When a new web content(corresponding to a particular structure, say A) is published, it should automatically get updated on the Asset Publisher portlet (default functionality of Asset Publisher).
By default the Title of the web content is what appears as a link on the Asset Publisher for different web contents. Instead of this I want the content of an element (say name) of structure A to appear as a link. Clicking on this link should open an Alloy UI Popup containing the corresponding Web content.
For this to happen I created a new 'display style' jsp using hooks (tweaked the abstracts.jsp).
Wrote this scriptlet in the .jsp
:
<%
String personName=null;
JournalArticle journalArticle=null;
String myContent=null;
Document document = null;
Node node=null;
Node node1=null;
Node node2=null;
Node node3=null;
int noOfWords=0;
String pic=null;
String aboutMe=null;
double version=0;
try {
version=JournalArticleLocalServiceUtil.getLatestVersion(assetRenderer.getGroupId(), "14405");
journalArticle = JournalArticleLocalServiceUtil.getArticle(assetRenderer.getGroupId() , "14405",version);
myContent = journalArticle.getContent();
document = SAXReaderUtil.read(new StringReader(myContent));
node = document.selectSingleNode("/root/dynamic-element[@name='personName']/dynamic-content");
if (node.getText().length() > 0) {
personName = node.getText();
}
node1 = document.selectSingleNode("/root/dynamic-element[@name='pic']/dynamic-content");
if (node1.getText().length() > 0) {
pic = node1.getText();
}
node2 = document.selectSingleNode("/root/dynamic-element[@name='noOfWords']/dynamic-content");
if (node2.getText().length() > 0) {
noOfWords = Integer.parseInt(node2.getText());
}
node3 = document.selectSingleNode("/root/dynamic-element[@name='aboutMe']/dynamic-content");
if (node3.getText().length() > 0) {
aboutMe = node3.getText(). substring(0,noOfWords)+"....";
}
} catch (PortalException e) {
e.printStackTrace();
} catch (DocumentException e) {
e.printStackTrace();
}
%>
But here the articleId
needs to be hard coded.
I want to fetch the articleId
here as and when a new web content is published i.e. dynamically.
Which API should be used here?
Any help is appreciated.
Thanks.