Send Query Parameter to Menu Component

<% RenderingContext context = (RenderingCon text)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);

String currentPath = context.getPath();

String currentLibrary = context.getLibrary().getName();

Map myparams = new HashMap();

myparams.put("SiteAreas", currentLibrary+"/mySite/mySiteArea1,"+currentLibrary+"/mySite/mySiteArea2"); %>

Another Way of doing is


<%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY); %>

<% String currentPath = context.getPath(); //Getting the library relative path(Ex : /Library/Site/Sitearea/Content)

String lrp=context.getLibraryRelativePath();

String sublrp=lrp.substring(0,lrp.lastIndexOf("/"));

String currentLibrary =context.getLibrary().getName();

Map myparams=context.getRequestParameters();

myparams.put("sitearea", currentLibrary+sublrp); context.setRequestParameters(myparams); %>

//Rendering the menu

<wcm:libraryComponent name="menu" library=currrentLibrary />

2 comments:

  1. Hi,

    I have a question. If we have comma in the site area name and title. It is not working. I think it is thinking as two site areas
    Eg:
    site name - January 1, 2015
    myparams.put("SiteAreas", "January 1, 2015"); %>

    ReplyDelete
  2. Did you try the html encoding of the "," comma i.e. %2C.

    ReplyDelete