DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Custom breadcrumb control

Sort:
You are not authorized to post a reply.





New Around Here





    Hello,

    I am trying to replicate and extend the native breadcrumbs control. I have made a copy of the files but in the code behind, I am not able to compile the code because it uses Globals.DependencyProvider that is marked as internal to the platform. This is used to get the INavigationManager.

    In this PR ( https://github.com/dnnsof...orm/pull/2795 ) is the correct way of using DI, using the correct base classes, but for what I can see, this was not implemented in the SkinObjectBase. 

    So I think I have 2 options:
    - Request that SkinObjectBase also has access to the DI;
    - Use another class as base for this control. Ex: SkinBase already has a navigation manager accessible.

    Does anyone have some kind of advice on how to go from here?

    Thanks!






    Veteran Member





      Maybe not a direct anwer to your question but you can also create breadcrumbs using DDR menu.
      As that's fully templatable, there might not be a need to fork the breadcrumbs at all.

      Examples: https://demo.40fingers.ne...Examples/Breadcrumbs






      New Around Here





        Thanks Timo!
        I will give it a go and try to get away with DDR and xslt.
        Actually I also wanted to add some special context and rules on some nodes based on conditions stored in portal settings, but that might be done using custom tokens ou something similar I suppose.

        Anyway, I will keep looking for a workaround for this Dependency injection on SkinBase derived components.





        Veteran Member





          You can switch DDR to use a Razor template and do all of the programming that you need to do.

          I think that there are lots of us who have a lot to learn about using the new DI stuff ...
          Joe Craig
          DNN MVP
          Patapsco Research Group





          New Around Here





            Tanks Timo and Joe!

            Wow, the power of DDR is almost infinite.
            I managed to use it with one of the Timo's templates for breadcrumbs and added some TemplateArguments so I can implement my logic.
            The goal was to add special links connecting parent / child portals based on portal settings and that was accomplished.

            Thanks guys!

            In case someone else is looking for a similar solution, this is what I've done:
            Created an ASCX for my breadcrumb control.

            <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AlgoBreadCrumbs.ascx.cs" Inherits=".....AlgoBreadCrumbs" %>

            <%@ Register TagPrefix="ddr" TagName="MENU" Src="~/DesktopModules/DDRMenu/Menu.ascx" %>

            <%@ Register TagPrefix="ddr" Namespace="DotNetNuke.Web.DDRMenu.TemplateEngine" Assembly="DotNetNuke.Web.DDRMenu" %>

            <ddr:menu id="mnuBreadCrumb" menustyle="Menus/Breadcrumbs" runat="server">



            In the code behind, I just add the template args when child controls are created:

            public partial class AlgoBreadCrumbs : SkinObjectBase
                {
                    public string ParentPortalLink { get; set; } = "https://someportal";
                    public string ParentPortalName { get; set; } = "Parent Portal";

                    /*DDR menu structure and parames takenfrom this thread:
                    https://dnncommunity.org/forums/aft/1286#4501
                    */
                    public AlgoBreadCrumbs()
                    {
                    }

                    protected override void CreateChildControls()
                    {
                        base.CreateChildControls();
                        SetMenuTemplateArgs();
                    }

                    private void SetMenuTemplateArgs() {
                        if (mnuBreadCrumb.TemplateArguments == null)
                            mnuBreadCrumb.TemplateArguments = new System.Collections.Generic.List();

                        mnuBreadCrumb.TemplateArguments.Add(new DotNetNuke.Web.DDRMenu.TemplateEngine.TemplateArgument { Name = "ParentPortalLink", Value = ParentPortalLink });
                        mnuBreadCrumb.TemplateArguments.Add(new DotNetNuke.Web.DDRMenu.TemplateEngine.TemplateArgument { Name = "ParentPortalName", Value = ParentPortalName });
                    }
                }

             



            Finally I add the params to the xsl template:

            xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

            xsl:output method="html"

            xsl:param name="ParentPortalLink"

            xsl:param name="ParentPortalName"


            Once again, thanks guys!






            Veteran Member





              Yes, DDR is pretty powerful. So that's why, for most applications I use the UlTokens template!
              Joe Craig
              DNN MVP
              Patapsco Research Group
              You are not authorized to post a reply.

              These Forums are dedicated to the discussion of DNN Platform.

              For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

              1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
              2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
              3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
              4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
              5. No Flaming or Trolling.
              6. No Profanity, Racism, or Prejudice.
              7. Site Moderators have the final word on approving / removing a thread or post or comment.
              8. English language posting only, please.

              Would you like to help us?

              Awesome! Simply post in the forums using the link below and we'll get you started.

              Get Involved