Foren

Appending the parameter to community home page URL

Sunil Kulkarni, geändert vor 11 Jahren.

Appending the parameter to community home page URL

Junior Member Beiträge: 94 Beitrittsdatum: 24.06.11 Neueste Beiträge
Hello All,

I have done following :
1. I have created open community named with 'bookshelf'. This community having only one page with layout 1 column.
2. I have create a portlet 'Books' and I have deployed that portlet on home page of the 'bookshelf' community. This book portlet having category wise data.

Now, the friendly url generated for the community 'bookshelf' is http://localhost:8080/web/bookshelf/home. So when any user directly copy and paste this URL in the browser, he can see the 'books' portlet.

Now I am achieving following:
Any user can give the category as parameter to the books portlet so that according to the parameter the book portlet will display the listing of the books.
e.g. If I typed http://localhost:8080/web/bookshelf/home?category=technical then book portlet should display the listing of books for category technical and if I typed http://localhost:8080/web/bookshelf/home?category=medical then book portlet should display the listing for medical category.

My question is :
Is this a valid way to pass this category parameter as mentioned above. In liferay, we are not directly appending the parameter as mentioned above.

Any thoughts will be very helpful.
Sunil Kulkarni, geändert vor 11 Jahren.

RE: Appending the parameter to community home page URL(Resolved)

Junior Member Beiträge: 94 Beitrittsdatum: 24.06.11 Neueste Beiträge
I have resoved this issue using portlet friendly URL.

I did the following :
1. Created a bookshelf.xml for friendly url
it contains following:
     <routes>
          <route>
	<pattern>/{categoryName}</pattern>
	<generated-parameter name="categoryName">{categoryName}</generated-parameter>
          </route>
      </routes>

2. Added the following in liferay-portlet.xml
     <friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
     <friendly-url-mapping>bookshelf</friendly-url-mapping>
     <friendly-url-routes>bookshelf.xml</friendly-url-routes>


3. Now my friendly URL is http://localhost:8080/web/bookshelf/home/-/bookshelf/technical

4. I can access categoryName in my portlet using
String categoryName = ParamUtil.get(request, "categoryName", "");
Praveen Motamarri, geändert vor 11 Jahren.

RE: Appending the parameter to community home page URL

New Member Beitrag: 1 Beitrittsdatum: 05.02.10 Neueste Beiträge
You can retrieve the parameter in the jsp like this
String category = PortalUtil.getOriginalServletRequest(request).getParameter("category");