2014-01-09 116 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