2014-01-09 89 views
1

我们的团队构建了一个自定义portlet以将Google标记加载到地图上。标记在模板脚本中创建。我们现在希望在另一个资产发布者中以列表形式显示这些标记。无论如何要根据请求它的portlet将条件传递给模板文件?或者,有没有什么好的方法可以将这些代码构建到jsp中而不是模板文件中?如何在liferay中构建特定于portlet的portlet

//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的概念性想法。非常感激你的帮助。

+0

如果我们找不到解决方案,我们将不得不为每个实例创建两个Web内容资产。这将是非常难以管理的,并且是最后的选择。 – coltonfranco

回答

0

如果你想使用相同的JavaScript函数从不同的portlet,那么更好的办法是把JavaScript函数主题

http://www.liferay.com/documentation/liferay-portal/6.2/development/-/ai/creating-themes-and-layout-templates-liferay-portal-6-2-dev-guide-09-en

并调用该函数从portlet的JSP不同属性。

+0

我们试图阻止java脚本函数在其他portlet中运行。有没有一种方法可以将代码放入jsp中并保持功能? – coltonfranco

+0

我不明白你的意思:(如果你想在两个不同格式的地方显示地图 - 那么建议把函数(谷歌地图是JavaScript API)放在中心位置,比如Liferay Theme,然后从你的电话中调用它Portlet或Web内容或其他所有内容。 – Mark