Foros de discusión

Breadcrumb trail

neelam bhandari, modificado hace 12 años.

Breadcrumb trail

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi,

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

Regards
Neelam Bhandari
thumbnail
Josef Šustáček, modificado hace 12 años.

RE: Breadcrumb trail

New Member Mensajes: 22 Fecha de incorporación: 5/10/09 Mensajes recientes
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 :

portal-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, modificado hace 12 años.

RE: Breadcrumb trail

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
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, modificado hace 12 años.

RE: Breadcrumb trail

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi,
Waiting reply from Liferay Team. Is there any way to achieve this in the current system?

Thanks
Neelam
thumbnail
Tejas Kanani, modificado hace 12 años.

RE: Breadcrumb trail

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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, modificado hace 12 años.

RE: Breadcrumb trail

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
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
thumbnail
Tejas Kanani, modificado hace 12 años.

RE: Breadcrumb trail

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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.

private void _buildLayoutBreadcrumb(Layout selLayout, String selLayoutParam, PortletURL portletURL, ThemeDisplay themeDisplay, boolean selectedLayout, StringBundler sb) throws Exception {
	String layoutURL = _getBreadcrumbLayoutURL(selLayout, selLayoutParam, portletURL, themeDisplay);
	String target = PortalUtil.getLayoutTarget(selLayout);

	StringBundler breadcrumbSB = new StringBundler(7);

	[b]if(selLayout.hasChildren())
	{
		breadcrumbSB.append("<li><span><a href="\&quot;&quot;);" breadcrumbsb.append(layouturl); breadcrumbsb.append("\" "); breadcrumbsb.append(target); breadcrumbsb.append(">");

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

		breadcrumbSB.append("</a></span></li>");
	}
	else
	{
		breadcrumbSB.append("<li><span>");
		breadcrumbSB.append(HtmlUtil.escape(selLayout.getName(themeDisplay.getLocale())));
		breadcrumbSB.append("</span></li>");
	}[/b]

	if (selLayout.getParentLayoutId() != LayoutConstants.DEFAULT_PARENT_LAYOUT_ID) {
		Layout layoutParent = LayoutLocalServiceUtil.getLayout(selLayout.getGroupId(), selLayout.isPrivateLayout(), selLayout.getParentLayoutId());

		_buildLayoutBreadcrumb(layoutParent, selLayoutParam, portletURL, themeDisplay, false, sb);

		sb.append(breadcrumbSB.toString());
	}
	else {
		sb.append(breadcrumbSB.toString());
	}
}


Let me know if it will not work for you.

Regards,
Tejas Kanani
Deploy Liferay to Jelastic Cloud
neelam bhandari, modificado hace 12 años.

RE: Breadcrumb trail

Regular Member Mensajes: 102 Fecha de incorporación: 16/08/11 Mensajes recientes
Hi Tejas,
Thanks a ton for the solution.I will try this and come back to you.
Cheers
Neelam Bhandari
surendrababu challa, modificado hace 12 años.

RE: Breadcrumb trail

New Member Mensajes: 12 Fecha de incorporación: 14/03/12 Mensajes recientes
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
thumbnail
Tejas Kanani, modificado hace 12 años.

RE: Breadcrumb trail

Liferay Master Mensajes: 654 Fecha de incorporación: 6/01/09 Mensajes recientes
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.
thumbnail
Brian Scott Schupbach, modificado hace 11 años.

RE: Breadcrumb trail

Expert Mensajes: 329 Fecha de incorporación: 23/10/08 Mensajes recientes
You can also use

#breadcrumbs()

In your velocity template file.
thumbnail
Amruta Naidu, modificado hace 10 años.

RE: Breadcrumb trail

New Member Mensajes: 12 Fecha de incorporación: 24/04/13 Mensajes recientes
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.

Archivos adjuntos:

thumbnail
M J, modificado hace 10 años.

RE: Breadcrumb trail

Regular Member Mensajes: 184 Fecha de incorporación: 1/03/13 Mensajes recientes
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.
pandiyan arumugam, modificado hace 8 años.

RE: Breadcrumb trail

New Member Mensajes: 8 Fecha de incorporación: 3/07/15 Mensajes recientes
Hi All,

Recently i have migrated to liferay 6.2 and no code change in html/taglib/ui/breadcrumb. But while accessing ui getting below Errror in server.log.


Error:-


21:09:19,996 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[jsp]] () Servlet.service() for servlet jsp threw exception: org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 197 in the jsp file: /html/taglib/ui/breadcrumb/init.jsp
Cannot make a static reference to the non-static method getPortletDisplay() from the type ThemeDisplay
194: }
195:
196: if (!showCurrentPortlet) {
197: PortletDisplay portletDisplay = ThemeDisplay.getPortletDisplay();
198:
199: String portletTitle = PortalUtil.getPortletTitle(portletDisplay.getId(), themeDisplay.getUser());
200:


Stacktrace:
at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:446) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:362) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:340) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:607) [jbossweb-7.0.13.Final.jar:]
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrap