Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
neelam bhandari
Breadcrumb trail
November 15, 2011 8:52 AM
Answer

neelam bhandari

Rank: Regular Member

Posts: 102

Join Date: August 16, 2011

Recent Posts

Hi,

Is it possible to show only text not url for the current page in breadcrumb trail?

Regards
Neelam Bhandari
Josef Šustáček
RE: Breadcrumb trail
November 15, 2011 12:25 PM
Answer

Josef Šustáček

Rank: New Member

Posts: 22

Join Date: October 5, 2009

Recent Posts

Hi,

I don't know whether there is some setting for it (doubt it), so I just grepped the source code and found out that breadcrumbs are generated via Velocity macro -> theme.getBreadcrumTag() -> breadcrumb tag (with default settings) from liferay-ui taglib.

So if you are comfortable with modifiing Liferay sources, try to look at files init.jsp and display_style_1.jsp in folder :

1portal-web/docroot/html/taglib/ui/breadcrumb/


try to find where link for current page is generated and update the code to be just a plain text.
neelam bhandari
RE: Breadcrumb trail
November 16, 2011 1:09 AM
Answer

neelam bhandari

Rank: Regular Member

Posts: 102

Join Date: August 16, 2011

Recent Posts

Hi ,
Many thanks for your reply. I was exactly trying the same . I did change init.jsp but nothing much happened

private void _buildPortletBreadcrumb(HttpServletRequest request, StringBundler sb) throws Exception {
List<KeyValuePair> portletBreadcrumbList = PortalUtil.getPortletBreadcrumbList(request);

if (portletBreadcrumbList == null) {
return;
}


for (KeyValuePair kvp : portletBreadcrumbList) {
if(kvp== getLast(portletBreadcrumbList)){
String breadcrumbText = kvp.getKey();
sb.append("<li><span>");
sb.append(HtmlUtil.escape(breadcrumbText));
sb.append("</span></li>");
}else{

String breadcrumbText = kvp.getKey();
String breadcrumbURL = kvp.getValue();

sb.append("<li><span>");

if (Validator.isNotNull(breadcrumbURL)) {
sb.append("<a href=\"");
sb.append(HtmlUtil.escape(breadcrumbURL));
sb.append("\">");
}

sb.append(HtmlUtil.escape(breadcrumbText));

if (Validator.isNotNull(breadcrumbURL)) {
sb.append("</a>");
}

sb.append("</span></li>");
}
}
}
KeyValuePair getLast(List<KeyValuePair> list) { return list.get(list.size() -1); }



I guess i need to change some other method in init.jsp.
If you come across some solution then kindly let me know
Regards
Neelam Bhandari
neelam bhandari
RE: Breadcrumb trail
November 16, 2011 4:23 AM
Answer

neelam bhandari

Rank: Regular Member

Posts: 102

Join Date: August 16, 2011

Recent Posts

Hi,
Waiting reply from Liferay Team. Is there any way to achieve this in the current system?

Thanks
Neelam
Tejas Kanani
RE: Breadcrumb trail
November 16, 2011 6:57 PM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hi Neelam,

Try out below change.

In display_style_1.jsp there is a method _buildLayoutBreadcrumb(). In that method modify below lines of code

StringBundler breadcrumbSB = new StringBundler(7);

breadcrumbSB.append("<li><span><a href=\"");
breadcrumbSB.append(layoutURL);
breadcrumbSB.append("\" ");
breadcrumbSB.append(target);
breadcrumbSB.append(">");

breadcrumbSB.append(HtmlUtil.escape(selLayout.getName(themeDisplay.getLocale())));

breadcrumbSB.append("</a></span></li>");


with

StringBundler breadcrumbSB = new StringBundler(7);

breadcrumbSB.append("<li><span>");
breadcrumbSB.append(HtmlUtil.escape(selLayout.getName(themeDisplay.getLocale())));
breadcrumbSB.append("</span></li>");


Now it will not display pages with the link. It will display only page title as a text format.

I hope that is what you are looking for.

Regards,
Tejas Kanani
Deploy Liferay to Jelastic Cloud
neelam bhandari
RE: Breadcrumb trail
November 17, 2011 1:41 AM
Answer

neelam bhandari

Rank: Regular Member

Posts: 102

Join Date: August 16, 2011

Recent Posts

Hi Tejas ,
Many thanks for your reply. I did try this solution yesterday .It does solve problem for the main page but for child (also hidden) pages I want url for the parent page in the bread crumb and not for the child one. In short I want text only for the last(current) page in the breadcrumb trail. This solution removes url from all the pages.

If you have further ideas regarding this problem kindly let me know.

Cheers
Neelam Bhandari
Tejas Kanani
RE: Breadcrumb trail
November 17, 2011 3:02 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Here you go !!!

Below is the modified _buildLayoutBreadcrumb() method as per your needs. Now it will display all the parent pages with link and child page(last page) will not have link in breadcrumb.

 1private void _buildLayoutBreadcrumb(Layout selLayout, String selLayoutParam, PortletURL portletURL, ThemeDisplay themeDisplay, boolean selectedLayout, StringBundler sb) throws Exception {
 2    String layoutURL = _getBreadcrumbLayoutURL(selLayout, selLayoutParam, portletURL, themeDisplay);
 3    String target = PortalUtil.getLayoutTarget(selLayout);
 4
 5    StringBundler breadcrumbSB = new StringBundler(7);
 6
 7    [b]if(selLayout.hasChildren())
 8    {
 9        breadcrumbSB.append("<li><span><a href=\"");
10        breadcrumbSB.append(layoutURL);
11        breadcrumbSB.append("\" ");
12        breadcrumbSB.append(target);
13        breadcrumbSB.append(">");
14
15        breadcrumbSB.append(HtmlUtil.escape(selLayout.getName(themeDisplay.getLocale())));
16
17        breadcrumbSB.append("</a></span></li>");
18    }
19    else
20    {
21        breadcrumbSB.append("<li><span>");
22        breadcrumbSB.append(HtmlUtil.escape(selLayout.getName(themeDisplay.getLocale())));
23        breadcrumbSB.append("</span></li>");
24    }[/b]
25
26    if (selLayout.getParentLayoutId() != LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
27        Layout layoutParent = LayoutLocalServiceUtil.getLayout(selLayout.getGroupId(), selLayout.isPrivateLayout(), selLayout.getParentLayoutId());
28
29        _buildLayoutBreadcrumb(layoutParent, selLayoutParam, portletURL, themeDisplay, false, sb);
30
31        sb.append(breadcrumbSB.toString());
32    }
33    else {
34        sb.append(breadcrumbSB.toString());
35    }
36}


Let me know if it will not work for you.

Regards,
Tejas Kanani
Deploy Liferay to Jelastic Cloud
neelam bhandari
RE: Breadcrumb trail
November 18, 2011 4:25 AM
Answer

neelam bhandari

Rank: Regular Member

Posts: 102

Join Date: August 16, 2011

Recent Posts

Hi Tejas,
Thanks a ton for the solution.I will try this and come back to you.
Cheers
Neelam Bhandari
surendrababu challa
RE: Breadcrumb trail
March 19, 2012 11:20 PM
Answer

surendrababu challa

Rank: New Member

Posts: 12

Join Date: March 13, 2012

Recent Posts

hi,

I have the sam problem.

I used ur code but I am getting console error
ERROR [IncludeTag:154] org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 31 in the jsp file: /html/taglib/ui/breadcrumb/display_style_horizontal.jsp
The method _buildLayoutBreadcrumb(Layout, String, PortletURL, ThemeDisplay, boolean, StringBundler) in the type display_005fstyle_005fhorizontal_jsp is not applicable for the arguments (Layout, String, boolean, PortletURL, ThemeDisplay, StringBundler)
28: }
29:
30: if (showLayout) {
31: _buildLayoutBreadcrumb(selLayout, selLayoutParam, true, portletURL, themeDisplay, sb);
32: }

please suggest any solution
Tejas Kanani
RE: Breadcrumb trail
April 2, 2012 12:11 AM
Answer

Tejas Kanani

Rank: Liferay Master

Posts: 653

Join Date: January 6, 2009

Recent Posts

Hi surendrababu challa,

looks like there is some error in your jsp file.
Can you please attach your jsp file here OR paste the code. That will be easy for others to easily get into the exact issue.
Brian Scott Schupbach
RE: Breadcrumb trail
July 2, 2012 7:29 AM
Answer

Brian Scott Schupbach

Rank: Expert

Posts: 329

Join Date: October 23, 2008

Recent Posts

You can also use

#breadcrumbs()

In your velocity template file.
Amruta Naidu
RE: Breadcrumb trail
January 20, 2014 1:18 AM
Answer

Amruta Naidu

Rank: New Member

Posts: 12

Join Date: April 23, 2013

Recent Posts

Hi Tejas....

I used the above code reference to modify my init.jsp in html/taglib/ui/breadcrumb/init.jsp. according to my requirement.
My Requirement:
the breadcrumb should be as follows and multilingual :
(Guest Site) > (<a>Parent Page</a>) > (Current Page)
I also achieved this using liferay 6.1.
Recently i have migrated to liferay 6.2, and in html/taglib/ui/breadcrumb there is no previous version code. Do you have any idea where the breadcrumb related jsp s are?
and how should i proceed in LR 6.2 for my requirement.

Thanks.
Attachments: init.jsp (9.4k)
M J
RE: Breadcrumb trail
January 20, 2014 5:52 AM
Answer

M J

Rank: Regular Member

Posts: 183

Join Date: March 1, 2013

Recent Posts

Try tomcat-7.0.42\webapps\ROOT\html\portlet\breadcrumb or tomcat-7.0.42\webapps\ROOT\html\taglib\ui\breadcrumb
for breadcrumb portlet JSPs.