Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# Degrade 3/14/2007 11:01 AM
Does anybody know of a crumbtrail module before i make one myself?

Many thanks

Matt

PS If i do make one myself, i'll make sure it is added to CuyahogaContrib
# D3grade 3/15/2007 3:34 AM
Ok,

Well i have created one and it is available here for download.

I'm not sure how to add it to CuyahogaContrib so if someone wants to add it, your more than welcome.

This was pretty much my first module. I think it works well, though i'm not sure if the crumbtrail would have been better suited as a control similar to the navigation control, but i wanted to have a go at making a module anway.

Hope it comes in handy for everyone.

Matt
# swilliam 3/15/2007 11:02 AM
Matt

Thanks for the module - it looks very good.

In the past I have used normal web controls for these sorts of things and embedded them in the templates. It might be a lot quicker to use a module for a breadcrumb, however, because you can take advantage of cacheing.

Many thanks

Simon
# martijnb 3/15/2007 1:00 PM
I think output caching for a breadcrumb module isn't going to work because of the dynamic nature of it (output cache doesn't know on what page the module is, so you might get the wrong breadcrumb trail).

Fortunately, the module uses the ActiveNode property of the Page and these objects are also cached by NHibernate's second level cache.
# D3grade 3/15/2007 1:58 PM
Does that mean i did a good job? :D

I think simon is probably right that it should have been just a control like the nav, but like i said, it was my first module and really just me getting to grips with modules in a relativley simple way.

# swilliam 3/15/2007 2:37 PM (edited 3/15/2007 2:40 PM)
What if you set the module's CacheKey to include the Node ID?

Interestingly, our internal CatalogueView module is using a web service as a data source and, with the selection of a good CacheKey value, it's exceptionally fast.
# hobbis 6/12/2008 1:33 PM
I converted a breadcrumb module to a Control if anyone is interested. CSS included too. It's a quick convert and I know there are a couple of problems but it's a first attempt. Thank you to the original developer though. Hope you haven't taken any offence by me doing this.
#breadcrumb-control-id
{
	margin:0;
	padding:0;
	list-style:none;
}

#breadcrumb-control-id li
{
	margin:0;
	padding:0;
	display:inline;
}

#breadcrumb-control-id li a
{
	padding:0 10px 0 10px;
	background:url(/Templates/maxplay/Images/breadcrumb-arrow.gif) no-repeat left 50%;
	font-weight:bold;
}

#breadcrumb-control-id li.breadcrumb-control-class-selected a
{
	font-weight:normal;
}

ul.breadcrumb-control-class
{
}

li.breadcrumb-control-class-home
{
	

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Cuyahoga.Core.Domain;
using Cuyahoga.Web.UI;
using Cuyahoga.Web.Util;

namespace Cuyahoga.Web.Controls.Navigation
{
    public partial class BreadCrumb : System.Web.UI.UserControl
    {
        private Repeater rptbreadcumb = new Repeater();
        private Cuyahoga.Web.UI.PageEngine _page;
        private bool flgHasContent = false;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page is PageEngine)
            {
                this._page = (PageEngine)this.Page;
                BuildNavigationBreadcrumb();
            }
            
            
            
        }

        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            rptbreadcumb.ItemDataBound += new RepeaterItemEventHandler(rptdb_ItemDataBound);
        }

        private void BuildNavigationBreadcrumb()
        {
            rptbreadcumb.DataSource = this._page.RootNode.NodePath[0].ChildNodes;
            rptbreadcumb.DataBind();

            //It renders the "ul" label only if there is content
            if (flgHasContent)
            {
                HtmlGenericControl List = new HtmlGenericControl("ul");
                List.Attributes.Add("id", "breadcrumb-control-id");
                List.Attributes.Add("class", "breadcrumb-control-class");

                //check if the "admim" tab has to be rendered
                //if (_module.FirstLevel <= 1)
                //{
                //    if (this._page.CuyahogaUser != null
                //        && this._page.CuyahogaUser.HasPermission(AccessLevel.Administrator))
                //    {
                //        HtmlGenericControl lstItem = new HtmlGenericControl("li");
                //        HyperLink hpl = new HyperLink();
                //        hpl.NavigateUrl = this._page.ResolveUrl("~/Admin");
                //        hpl.Text = "Admin";
                //        lstItem.Controls.Add(hpl);
                //        List.Controls.Add(lstItem);
                //    }
                //}

                //check if "home" item has to be rendered or not
                //if (_module.FirstLevel == 0)
                //{
                    HyperLink hpli = new HyperLink();
                    HtmlGenericControl lstItemi = new HtmlGenericControl("li");
                    hpli.NavigateUrl = UrlHelper.GetUrlFromNode(this._page.RootNode);
                    UrlHelper.SetHyperLinkTarget(hpli, this._page.RootNode);
                    hpli.Text = this._page.RootNode.Title;
                    lstItemi.Controls.Add(hpli);
                    lstItemi.Attributes.Add("class", "breadcrumb-control-class-home");
                    List.Controls.Add(lstItemi);
                //}

                //add the "ul" control to the placeholder


                List.Controls.Add(rptbreadcumb); //add the repeater to de "ul" control
                plHolder.Controls.Add(List);

            }
        }

         void renderBreadcrumb(Node node, RepeaterItemEventArgs e)
        {
            // Bind child nodes
            Repeater rptChildsmiga = new Repeater();
            Control List = new Control();

            //checks if is necesary to render the "ul" control
            if (node.Level >= 0)
            {
                List = new HtmlGenericControl("li");
            }

            List.Controls.Add(rptChildsmiga);
            e.Item.Controls.Add(List);
            rptChildsmiga.ItemDataBound += new RepeaterItemEventHandler(this.rptdb_ItemDataBound);
            rptChildsmiga.DataSource = node.ChildNodes;
            rptChildsmiga.DataBind();

        }

        void rptdb_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
        {

            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Node node = (Node)e.Item.DataItem;
                //check permissions the range of menu level to render. lastLevel=-1 to render untill the end
                HyperLink hpl = new HyperLink();
                HtmlGenericControl lstItem = new HtmlGenericControl("li");
                if (node.Id != this._page.ActiveNode.Id)
                {
                    hpl.NavigateUrl = UrlHelper.GetUrlFromNode(node);

                }
                if (node.Id != this._page.ActiveNode.Id) { }
                else { lstItem.Attributes.Add("class", "breadcrumb-control-class-selected"); }



                UrlHelper.SetHyperLinkTarget(hpl, node);

                //Check if the node is in Trail to apply a specific CSS class
                foreach (int Id in this._page.ActiveNode.Trail)
                {
                    if (this._page.ActiveNode.ParentNode != null)
                    {
                        if (node.Id == Id || node.Id == this._page.ActiveNode.Id)
                        {


                            hpl.Text = node.Title;
                            lstItem.Controls.Add(hpl);
                            flgHasContent = true;
                            e.Item.Controls.Add(lstItem);
                            if (node.ChildNodes.Count > 0)
                            {
                                if (node.Level >= 1) { renderBreadcrumb(node, e); }
                            }

                        }
                    }
                    else
                    {
                        //This  node, is the "home" node , we can show  the  title of the home  in thes zone 

                    }
                }
            }
        }
    }
}
# ernesto 6/12/2008 3:39 PM
We made a module that renders nodes like menu or breadcrum style. Is available to download in CuyahogaContrib

You can see a screenshot here
# mayur 6/13/2008 3:52 PM (edited 6/18/2008 9:56 AM)
we made a quick and simple breadcrumb module too http://labs.magiclantern.co.uk/3/section.aspx/5


hope the domain resolved

# mayur 6/18/2008 9:57 AM

sorry the link should work now
# D3grade 6/18/2008 10:04 AM
Nice work guys