It looks like a Bug in Breadcrumbs

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
8/18/2011 4:03:36 AM
Gravatar
Total Posts 13

It looks like a Bug in Breadcrumbs

Hi,

I created a supporting page ,I need to display Breadcrumbs in this page showing the current page, the breadcrumb shows the correct path but it is missing the current page, so in order to display it, I wrote this code in the Page_Load event:

BreadcrumbsControl breadcrumbs = (BreadcrumbsControl)Master.FindControl("Breadcrumbs");
breadcrumbs.AddedCrumbs = "<a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a>";

 

and after the page is requested by the browser, the html code for the breadcrumb is like this :

<div id="ctl00_Breadcrumbs_pnlWrapper" class="breadcrumbs">

<span id="ctl00_Breadcrumbs_breadCrumbsControl"><span>

<a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl00_lnkNode" class="unselectedcrumb" href="/home.aspx">Home</a>
</span><span>/</span><span>
<a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl02_lnkCurrent" class="selectedcrumb" href="/products.aspx">Products</a>
</span></span>
<a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a>

</div>

as  it is shown the "<a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a>" out of the span which make it rendered in incorrect way

 

8/29/2011 6:38:49 AM
Gravatar
Total Posts 14

Re: It looks like a Bug in Breadcrumbs

Hello,

I am facing this problem too, any plan to fix this bug?

 

Regards

Tarek

8/29/2011 7:10:45 AM
Gravatar
Total Posts 18439

Re: It looks like a Bug in Breadcrumbs

Hi,

I suppose what you are calling a bug is that the extra AddedCrumbs are not inside the span that wraps the other crumbs.

Unfortunately there is nothing I can do about that, under the hood we are using a SiteMapPath control which is databound to the SiteMap and the added crumbs is just literal extra markup that we can inject after the markup generated by the SiteMapPath control, we don't have a way to get inside there.

My advice is just don't use those spans for styling then they will not affect anything. Apply styling only at the outer div and on the links and pretend those spans are not even there.  

Hope that helps,

Joe

8/29/2011 7:30:42 AM
Gravatar
Total Posts 13

Re: It looks like a Bug in Breadcrumbs

Hi,

Many Thanks  Joe, your suggestion makes sense, It will resolve my issue

Best Regard

Ali

8/29/2011 7:47:05 AM
Gravatar
Total Posts 18439

Re: It looks like a Bug in Breadcrumbs

Hi Guys,

I just looked into it further and I did find way to eliminate the outermost span. With the outermost span removed then you could add spans around your additional crumbs and they will be the same as other crumbs.

BreadcrumbsControl breadcrumbs = (BreadcrumbsControl)Master.FindControl("Breadcrumbs");
breadcrumbs.AddedCrumbs = "<span><a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a></span>";

Then you could use the spans for styling if you wanted to.

I think I could possibly eliminate all the spans if I implement a custom SiteMapNodeItem control and use it instead of the default one. But then you would also not be able to use them for styling.

Which solution do you think would be preferable?

  1. Just remove the outer span so you can then use spans on your added crumbs and then you could use the spans for styling
  2. Eliminate all the spans and just have links inside the out div

Basically the general problem and solution is described in this blog post. Many controls render spans but it is possible to get rid of them if you create a custom control that inherits from the original control, and then you override the Render event and just change it from base.Render(HtmlWriter); to base.RenderContents(htmlWriter); it then leaves out the span that would be the outer markup.

I removed the outmost span by doing this on our mojoSiteMapPath control. To get rid of the rest of them I would need to implement a custom SiteMapNodeItem control.

Best,

Joe

8/29/2011 10:03:59 AM
Gravatar
Total Posts 14

Re: It looks like a Bug in Breadcrumbs

Joe,

I believe the first suggestion is the best because it will keep the styling easier to add and modify, but I have two concerns regarding this solution:

1- If you implented it in this way, this could break the exiting websites that build on Mojo, as there are a few possibilites that a web desginer created a  breadcrumb style based on the original structure.

2- what about the possiblities of removing the from "selectedcrumb" class name from the last elemented added in the original implenetation, I think it is always the last element should be selected and has the css class "selectedcrumb", So HTML tags should be converted from 

 

<div id="ctl00_Breadcrumbs_pnlWrapper" class="breadcrumbs">
<span id="ctl00_Breadcrumbs_breadCrumbsControl"><span>
<a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl00_lnkNode" class="unselectedcrumb" href="/home.aspx">Home</a>
</span>
<span>/</span>

<span><a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl02_lnkCurrent" class="selectedcrumb" href="/products.aspx">Products</a>
</span></span>
<a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a>
</div>

 

to 

<div id="ctl00_Breadcrumbs_pnlWrapper" class="breadcrumbs">
<span><a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl00_lnkNode" class="unselectedcrumb" href="/home.aspx">Home</a></span>
<span>/</span>
<span><a id="ctl00_Breadcrumbs_breadCrumbsControl_ctl02_lnkCurrent" class="unselectedcrumb" href="/products.aspx">Products</a></span>
<span><a class="selectedcrumb" href="/Product-Details.aspx">Product Details</a></span>
</div>

 

Many Thanks

Tarek

8/29/2011 10:36:31 AM
Gravatar
Total Posts 18439

Re: It looks like a Bug in Breadcrumbs

Hi Tarek,

Sorry but I do not have a solution for that. We are just injecting some extra crumbs after what is rendered by the SiteMapPath control. It adds that selectedcrumb class because the current page is the active page based on the page id. There is not any easy way to change that after it has already been rendered and it is correct for the context of the CMS page involved.

What I've decided is to make it possible to render with or without the spans but the default will be without them since I think probably most people are not using those spans to style the links, but if someone reports a problem I can tell them how to restore the previous behavior by adding this to the theme.skin file:

<portal:SiteMapPath runat="server"
  RenderContentsOnly="false"
/>

<portal:mojoSiteMapNodeItem runat="server"
  RenderContentsOnly="false"
/>

So the first one controls whether that outer span is rendered and the second one determines if spans are created around the links and the path separators.

So the problem will remain that if you rely on that outer span then additional crumbs will not be inside it. Therefore the only useful choices are to leave out the outer one and then add spans on the added crumbs or to leave out all the spans and just use the div and the links to apply style. This last approach seems best to me since you and I don't have control over custom features developed by others that may add links to the crumbs so you cannot expect that they will always have spans. So historically those spans were not useful for styling anyway if there are extra crumbs added that did not include them.

Sorry I don't have a perfect solution but this is the best I can come up with at the moment.

Best,

Joe

8/29/2011 4:59:15 PM
Gravatar
Total Posts 14

Re: It looks like a Bug in Breadcrumbs

Hello Joe,

Thank you for the prompt response.

Regarding the outer span, I totally agree with you as there is no benefits for it.

As for the inner spans, I believe it give a big advantage for website designer in  applying different styles to both the links and separators, moreover, personally I like the idea of having the last link in the breadcrumb to have a different style, because  it shows where the website visitors are standing and it should be non-linkable;  by using the jquery/javascript  and CSS  selector and spans, we can control the styles 

 

Many Thanks

Tarek

You must sign in to post in the forums. This thread is closed to new posts.