Breadcrumbs and CSS

Store UI, layout, design, look and feel; Discussion on the customer facing pages of your online store. Cascading Style Sheets, Themes, Scriptlets, NVelocity and the components in the ConLib directory.
Post Reply
euroluxantiques
Commander (CMDR)
Commander (CMDR)
Posts: 118
Joined: Sat Dec 20, 2008 11:27 pm

Breadcrumbs and CSS

Post by euroluxantiques » Sat Aug 28, 2010 12:02 pm

I'm trying to figure out how to modify the code of CategoryBreadCrumbs.ascx.cs so that the last (lowest category level) would be displayed with CSSClass="lowestLevel" so that I can format just that last level in CSS. I can format all the breadcrumbs or just all the subcategories, but I want to format the last subcategory differently, sort of a "you are here" kind of thing. How can I modify the code to add a class to that last level to be able to hook it with CSS?

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Breadcrumbs and CSS

Post by mazhar » Mon Aug 30, 2010 12:24 am

Edit your ConLib/CategoryBreadCrumbs.asx file and locate following code in it

Code: Select all

<asp:HyperLink ID="BreadCrumbsLink" runat="server" NavigateUrl='<%#UrlGenerator.GetBrowseUrl((int)Eval("catalogNodeId"), (string)Eval("name"))%>' Text='<%#Eval("Name")%>'></asp:HyperLink>
Now update it as below

Code: Select all

<asp:HyperLink ID="BreadCrumbsLink" runat="server" NavigateUrl='<%#UrlGenerator.GetBrowseUrl((int)Eval("catalogNodeId"), (string)Eval("name"))%>' Text='<%#Eval("Name")%>' CssClass='<%#GetCssClass(Eval("CategoryId")) %>'></asp:HyperLink>
Finally edit the ConLib/CategoryBreadCrumbs.asx.cs file and add following method to it

Code: Select all

protected string GetCssClass(object value) 
    {
        Category category = CategoryDataSource.Load(_CategoryId);
        int previousCategoryId = AlwaysConvert.ToInt(value);
        
        string cssClass = string.Empty;
        if (category.ParentId == previousCategoryId)
            cssClass = "lastCategory";
        return cssClass;
    }
save it. Now try some styles against css class called lastCategory.

Post Reply