我们的团队构建了一个自定义 portlet,用于将 Google 标记加载到 map 上。标记是在模板脚本中创建的。我们现在希望以类似列表的格式在另一个 Assets 发布者中显示这些标记。无论如何,是否可以根据请求它的 portlet 将条件传递给模板文件?或者是否有任何好的方法可以将此代码构建到 jsp 而不是模板文件中?
//code that creates the markers on the full map
gmarker=new google.maps.Marker({position:new google.maps.LatLng("$Lattitude.getData()","$Longitude.getData()"),title:"$reserved-article-title.getData()",icon:gicon,map:map});
if(window.location.href.indexOf("fullmap") > -1) {
google.maps.event.addListener(gmarker, 'click', function() {
new google.maps.InfoWindow({content:
'<div id="node_content">
<div id="siteNotice"></div>
<h3 id="firstHeading" class="firstHeading">$reserved-article-title.getData(), $City.getData(), $Country.getData()</h3>
<hr class="m_spacer"/>
<div id="bodyContent">
<p class="gdes">$Description.getData()</p>
<img class="m_image" src="$Image.getData()"/>
</div>
</div>'
}).open(map,this);
});
}
gmarker.setMap(map);
//redirect code that opens the infowindow on load if the id paramater is not null
if(flag==true){new google.maps.InfoWindow({content:
'<div id="node_content" class="gs2">
<div id="siteNotice"></div>
<h3 id="firstHeading" class="firstHeading">$reserved-article-title.getData(), $City.getData(), $Country.getData()</h3>
<hr class="m_spacer"/>
<div id="bodyContent">
<p class="gdes">$Description.getData()</p>
<img class="m_image" src="$Image.getData()"/>
</div>
</div>'}).open(map,gmarker);
flag=false;
}
现在是 liferay 6.1,所以我们无法享受最新版本的奢华。 Here是两个 portlet 及其显示内容的屏幕截图,以及我们目标的示例。可以找到与我们正在尝试的非常相似的网站 here 。我们希望获得关于如何区分 portlet 的概念性想法,而不是代码。非常感激你的帮助。
最佳答案
如果您想在不同的 portlet 中使用相同的 JavaScript 函数,那么更好的方法是将 JavaScript 函数放入主题
并从具有不同属性的 portlet-jsp 调用该函数。
关于java - 如何在 liferay 中构建特定条件的 portlet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21024214/