Home > My Works, Tech, software > Liferay- Drop down Menu Portlet

Liferay- Drop down Menu Portlet

Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to FurlAdd to Newsvine

Here is my Next portlet. Hope you enjoyed the Liferay theme with multilevel dropdown menu. What if you can put that drop down menu as a portlet? Here is what I did for that.

drop down portlet1. Here let’s start by downloading the required files. [dropdown_menu portlet.zip]

2. Put these files in webapps\ROOT\html\portlet\ext\dropdown_menu\

3. Copy the following code to webapps\ROOT\WEB-INF\portlet-ext.xml under <portlet-app> tag

<portlet>
<portlet-name>dropdown_menu</portlet-name>
 <display-name>Dropdown Menu</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class>
 <init-param>
 <name>view-jsp</name>
 <value>/html/portlet/ext/dropdown_menu/view.jsp</value>
 </init-param>
 <expiration-cache>0</expiration-cache>
 <supports>
 <mime-type>text/html</mime-type>
 </supports>
 <resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
 <security-role-ref>
 <role-name>guest</role-name>
 </security-role-ref>
 <security-role-ref>
 <role-name>power-user</role-name>
 </security-role-ref>
 <security-role-ref>
 <role-name>user</role-name>
 </security-role-ref>
 </portlet>

4. Copy the following code to webapps\ROOT\WEB-INF\liferay-portlet-ext.xml under <portlets> tag

<portlet>
<portlet-name>dropdown_menu</portlet-name>
 <configuration-action-class>com.liferay.portlet.sitemap.action.ConfigurationActionImpl</configuration-action-class>
<portlet-data-handler-class>com.liferay.portlet.sitemap.lar.SitemapPortletDataHandlerImpl</portlet-data-handler-class>
 <use-default-template>true</use-default-template>
 <restore-current-view>false</restore-current-view>
 <layout-cacheable>true</layout-cacheable>
 <instanceable>true</instanceable>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
 <render-weight>50</render-weight>
 <header-portlet-css>/html/portlet/ext/dropdown_menu/css.jsp</header-portlet-css>
 <css-class-wrapper>portlet-site-map</css-class-wrapper>
 <add-default-resource>true</add-default-resource>
 </portlet>

5.  Also make an entry in webapps\ROOT\WEB-INF\liferay-display.xml under <category name=”category.cms”>> as follows

 <display>
 <category name="category.cms">
 ......
<portlet id="dropdown_menu" />
 </category>
 .......
 </display>

You can even customize the root folder for the  drop down menu.

Have you seen the dynamic sitemap portlet? This is a modification of that one. I applied CSS to display the sitemap portlet as a drop down menu. It works pretty well in Firefox and Ie.

  1. Chris
    June 9, 2009 at 8:05 pm | #1

    What version of Liferay are you using. In 5.2.3 on Tomcat 5.5, the directory structure you mention doesn’t exist…?

    • June 9, 2009 at 9:41 pm | #2

      @Chris
      I am using Liferay 5.2.2 on tomcat 6.0. Liferay 5.2.3 is having same directory structure as in 5.2.2. Are you working in ‘ext’ environment? My instructions are for directly creating portlet inside liferay. You must create a folders ‘ext’ and ‘dropdown_menu’ as specfied in path.
      If you are not able to find ‘liferay-portlet-ext.xml’ and ‘portlet-ext.xml’, create new files and paste the code under specified tags.

      • Chris
        June 11, 2009 at 9:16 pm | #3

        Sweet Shamzu — I started creating the directory structure hoping that would be your answer ; )

        I will now set up the XML files and paste in your code. Drop downs as a portlet should make a globally persistent navigation fairly straight-forward. I tried your google theme, but found that the jedi theme was a better basis for my customization. I am still constrained a little by Jedi so your portlet should be perfect.

        Thanks!

  2. Prakash
    August 11, 2009 at 11:50 am | #4

    Hello Shamzu,

    I followed your above steps. But unable to get the navigation CSS and Javascript Working.

    I am using the Liferay 5.1.5 Version

    Can you provide any help!

    Thank you

    • August 11, 2009 at 6:48 pm | #5

      @Prakash
      Upgrade your liferay to 5.2.2. I never tried this on 5.1.5.

  3. October 8, 2009 at 5:03 am | #6

    Hey Shamzu,
    Just tried it with Liferay 5.2.3
    Works like a charm.
    Thank you.

    • October 8, 2009 at 2:19 pm | #7

      @Landry
      Hi, Thanks for testing it on 5.2.3.

  4. June 11, 2009 at 9:57 pm | #8

    @Chris
    Nice to see your reply.. thanks :D

  1. No trackbacks yet.