protected void rptLanguages_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Item node = (Item)e.Item.DataItem;

                HyperLink LangLink = (HyperLink)e.Item.FindControl("LangLink");
                System.Web.UI.WebControls.Image LangImage = (System.Web.UI.WebControls.Image)e.Item.FindControl("LangImage");
                Literal LangIso = (Literal)e.Item.FindControl("LangIso");

                //check if context item has a language version
                Item contextItem    = Sitecore.Context.Item;
                Item itemInLanguage = Sitecore.Context.Database.GetItem(contextItem.ID, Sitecore.Globalization.Language.Parse(node.Name));

                if (node != null && SiteConfiguration.DoesItemExistInCurrentLanguage(itemInLanguage) && LangLink != null && LangImage != null && LangIso != null)
                {
                    string icon = node.Appearance.Icon;
                    icon = Sitecore.Resources.Images.GetThemedImageSource(icon);
                    LangImage.ImageUrl   = icon;
                    LangIso.Text         = node["iso"].ToLower();
                    LangLink.NavigateUrl = Configuration.SiteUI.Translation.SiteLanguage.GetLanguageUrl(node);

                    if (!multipleLanguagesHasBeenProcessed)
                    {
                        LiLanguages.Attributes.Add("class", "dropdown");
                        LanguageLink.Text += " <b class=\"caret\"></b>";
                        multipleLanguagesHasBeenProcessed = true;
                    }
                }
            }
        }
Пример #2
0
        private void Page_Load(object sender, EventArgs e)
        {
            /* Populate two ways:
             * 1. Children of Datasource
             * 2. Children of Current */
            List <Item> items = new List <Item>();

            foreach (Item item in DataSourceItemOrCurrentItem.Children)
            {
                if (SiteConfiguration.DoesItemExistInCurrentLanguage(item))
                {
                    items.Add(item);
                }
            }

            if (items.Count > 0)
            {
                rptList.DataSource = items;
                rptList.DataBind();
            }
            else
            {
                if (IsPageEditorEditing)
                {
                    WriteAlert("list is empty");
                }
            }
        }
        public ActionResult RelatedArticles()
        {
            /* make sure the datasource or current has children in the current language and render accordingly */
            List <SimpleItem> items = new List <SimpleItem>();

            //first get items related to me...
            MultilistField related = Sitecore.Context.Item.Fields["Prerequisite Articles"];

            if (related != null)
            {
                foreach (Item i in related.GetItems())
                {
                    if (SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                    {
                        items.Add(new SimpleItem(i));
                    }
                }
            }

            //now get items I am related to
            foreach (Item i in Sitecore.Context.Database.SelectItems(SiteConfiguration.GetFurtherReadingArticlesQuery(Sitecore.Context.Item.ID.ToString())))
            {
                if (SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                {
                    items.Add(new SimpleItem(i));
                }
            }

            // items.Sort(); // TODO: need to implement Comparer
            return(!items.IsNullOrEmpty() ? View(items) : ShowListIsEmptyPageEditorAlert());
        }
        public ActionResult SitesNavigation()
        {
            Item contentNode         = SiteConfiguration.GetHomeItem().Parent;
            List <GenericLink> sites = new List <GenericLink>();

            foreach (Item site in contentNode.Children.ToArray().Where(item => SiteConfiguration.DoesItemExistInCurrentLanguage(item)))
            {
                if (site["Show in Sites Menu"] == "1")
                {
                    sites.Add(new GenericLink(site["Site Name"], LinkManager.GetItemUrl(site), false));
                }
            }

            if (SiteConfiguration.GetExternalSitesItem() != null)
            {
                foreach (Item externalsite in SiteConfiguration.GetExternalSitesItem().Children)
                {
                    if (SiteConfiguration.DoesItemExistInCurrentLanguage(externalsite))
                    {
                        Sitecore.Data.Fields.LinkField lf = externalsite.Fields["Site Link"];
                        sites.Add(new GenericLink(lf.Text, lf.Url, true));
                    }
                }
            }

            // Don't show the drop down unless there are multiple sites
            return((sites.Count > 1) ? View("TertiaryNavigationPartialSites", sites as IEnumerable <GenericLink>) : null);
        }
Пример #5
0
        private void Page_Load(object sender, EventArgs e)
        {
            Item team = SiteConfiguration.GetTeamItem();

            if (team != null && team.Template.Key == "team section") //TODO: The team list should not show anything unless it is the team section.  This is enforced in page editor using placeholder settings.
            {
                rptList.DataSource = team.Children.ToArray().Where(item => SiteConfiguration.DoesItemExistInCurrentLanguage(item));
                rptList.DataBind();
            }
        }
 protected void HideIfNoVersionUnlessPageEditing()
 {
     if (IsDataSourceItemNull || !SiteConfiguration.DoesItemExistInCurrentLanguage(DataSourceItem))
     {
         if (!IsPageEditorEditing)
         {
             this.Visible = false;
         }
     }
 }
        private void LoadSitesList()
        {
            Item        contentNode   = SiteConfiguration.GetHomeItem().Parent;
            List <Item> sites         = new List <Item>();
            List <Item> externalsites = new List <Item>();

            foreach (Item site in contentNode.Children.ToArray().Where(item => SiteConfiguration.DoesItemExistInCurrentLanguage(item)))
            {
                if (site["Show in Sites Menu"] == "1")
                {
                    sites.Add(site);
                }
            }

            if (SiteConfiguration.GetExternalSitesItem() != null)
            {
                foreach (Item externalsite in SiteConfiguration.GetExternalSitesItem().Children)
                {
                    if (SiteConfiguration.DoesItemExistInCurrentLanguage(externalsite))
                    {
                        externalsites.Add(externalsite);
                    }
                }
            }

            if (sites.Count + externalsites.Count > 1) // Don't show the drop down unless there are multiple sites
            {
                SitesLink.Text = GetDictionaryText("Sites");
                if (sites.Count > 0)
                {
                    rptList.DataSource = sites;
                    rptList.DataBind();
                }

                if (sites.Count > 0 && externalsites.Count > 0)
                {
                    divider.Visible = true;
                }

                if (externalsites.Count > 0)
                {
                    rptExternal.DataSource = externalsites;
                    rptExternal.DataBind();
                }
            }
            else
            {
                SitesLink.Visible = false;
            }
        }
Пример #8
0
        protected void rptDropDownMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Item node = (Item)e.Item.DataItem;
                {
                    HyperLink   MenuLink = (HyperLink)e.Item.FindControl("MenuLink");
                    Literal     MenuText = (Literal)e.Item.FindControl("MenuText");
                    HtmlControl MenuLi   = (HtmlControl)e.Item.FindControl("MenuLi");

                    if (MenuLink != null && MenuText != null)
                    {
                        MenuText.Text        = node["Menu Title"];
                        MenuLink.NavigateUrl = LinkManager.GetItemUrl(node);
                        if (node.ID == Sitecore.Context.Item.ID)
                        {
                            MenuLi.Attributes.Add("class", "active");
                        }

                        if (node["Show Children In Menu"] == "1" && node.HasChildren && node.Parent.ID == HomeItem.ID)
                        {
                            MenuLi.Attributes.Add("class", "dropdown");
                            MenuLink.Attributes.Add("class", "dropdown-toggle");
                            MenuLink.Attributes.Add("data-toggle", "dropdown");
                            MenuText.Text += "  <b class=\"caret\"></b>";

                            PlaceHolder phSubTree = (PlaceHolder)e.Item.FindControl("phSubMenu");

                            List <Item> nodes = new List <Item>();
                            foreach (Item i in node.Children)
                            {
                                if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item In Menu"] == "1")
                                {
                                    nodes.Add(i);
                                }
                            }

                            Repeater rpt = new Repeater();
                            rpt.DataSource     = nodes;
                            rpt.HeaderTemplate = new TopBarRecursiveRepeaterTemplate(ListItemType.Header);
                            rpt.ItemTemplate   = rptDropDownMenu.ItemTemplate;
                            rpt.FooterTemplate = new TopBarRecursiveRepeaterTemplate(ListItemType.Footer);
                            rpt.ItemDataBound += new RepeaterItemEventHandler(rptDropDownMenu_ItemDataBound);
                            phSubTree.Controls.Add(rpt);
                            rpt.DataBind();
                        }
                    }
                }
            }
        }
        protected void rptTree_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Item node = (Item)e.Item.DataItem;
                {
                    HyperLink     MenuLink = (HyperLink)e.Item.FindControl("MenuLink");
                    FieldRenderer MenuText = (FieldRenderer)e.Item.FindControl("MenuText");

                    if (MenuLink != null && MenuText != null)
                    {
                        MenuLink.NavigateUrl = LinkManager.GetItemUrl(node);
                        MenuText.Item        = node;

                        // determine if the current item is a descendant
                        if (Sitecore.Context.Item.ID == node.ID || node.Axes.SelectItems(String.Format(".//*[@@id = '{0}']", Sitecore.Context.Item.ID)) != null) // do not compare nodes as it is faster to compare ids.
                        {
                            // apply active state to the current item.
                            if (Sitecore.Context.Item.ID == node.ID)
                            {
                                MenuLink.Attributes.Add("class", "active");
                            }

                            // now load the children since this is the selected node
                            if (node.HasChildren)
                            {
                                PlaceHolder phSubTree = (PlaceHolder)e.Item.FindControl("phSubTree");
                                Repeater    rpt       = new Repeater();
                                List <Item> nodes     = new List <Item>();
                                foreach (Item i in node.Children)
                                {
                                    if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item in Secondary Menu"] == "1")
                                    {
                                        nodes.Add(i);
                                    }
                                }
                                rpt.DataSource     = nodes;
                                rpt.HeaderTemplate = rptTree.HeaderTemplate;
                                rpt.ItemTemplate   = rptTree.ItemTemplate;
                                rpt.FooterTemplate = rptTree.FooterTemplate;
                                rpt.ItemDataBound += new RepeaterItemEventHandler(rptTree_ItemDataBound);
                                phSubTree.Controls.Add(rpt);
                                rpt.DataBind();
                            }
                        }
                    }
                }
            }
        }
Пример #10
0
        public ActionResult FooterNavigation()
        {
            Item baseItem = SiteConfiguration.GetFooterLinksItem();
            List <SimpleNavigationItem> items = new List <SimpleNavigationItem>();

            foreach (Item footerLink in baseItem.Children)
            {
                Item i = Sitecore.Context.Database.GetItem(footerLink["Top Level Item"]);
                if (i != null && SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                {
                    items.Add(new SimpleNavigationItem(i));
                }
            }

            return(View(items));
        }
 /// <summary>
 /// Automatically resets the Context item to the specified datasource if not null
 /// </summary>
 /// <param name="writer"></param>
 protected void WriteAlertsIfNeeded()
 {
     if (IsDataSourceItemNull)
     {
         if (IsPageEditorEditing)
         {
             WriteAlert("datasource is null");
         }
     }
     else if (!SiteConfiguration.DoesItemExistInCurrentLanguage(DataSourceItem))
     {
         if (IsPageEditorEditing)
         {
             WriteAlert("no version in current language");
         }
     }
 }
        public ActionResult FooterNavigation()
        {
            List <SimpleNavigationItem> items = new List <SimpleNavigationItem>();
            Item homeItem = SiteConfiguration.GetHomeItem();

            if (homeItem != null)
            {
                if (homeItem["Show Item In Footer Menu"] == "1" && SiteConfiguration.DoesItemExistInCurrentLanguage(homeItem))
                {
                    items.Add(new SimpleNavigationItem(homeItem));
                }
                foreach (Item i in homeItem.Axes.GetDescendants().Where(x => x["Show Item In Footer Menu"] == "1" && SiteConfiguration.DoesItemExistInCurrentLanguage(x)))
                {
                    items.Add(new SimpleNavigationItem(i));
                }
            }
            return(items.Count > 0 ? View(items) : null);
        }
        private void Page_Load(object sender, EventArgs e)
        {
            // The tree menu is basically the secondary navigation for the site.
            // The datasource needs to be one level off the home node.
            Item home       = SiteConfiguration.GetHomeItem();
            Item dataSource = Sitecore.Context.Item;

            if (home.ID != dataSource.ID) // if on the home node, just use it
            {
                while (dataSource.ParentID != home.ID)
                {
                    dataSource = dataSource.Parent;
                }
            }

            MenuHeader.Item = dataSource;

            // now we can populate the tree.
            List <Item> nodes = new List <Item>();

            foreach (Item i in dataSource.Children)
            {
                if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item in Secondary Menu"] == "1")
                {
                    nodes.Add(i);
                }
            }

            if (nodes.Count > 0)
            {
                rptTree.DataSource = nodes;
                rptTree.DataBind();
            }
            else
            {
                menuWrapper.Visible = false;
                if (IsPageEditorEditing)
                {
                    WriteAlert("list is empty");
                }
            }
        }
        private void Page_Load(object sender, EventArgs e)
        {
            List <Item> backgroundItems = new List <Item>();
            List <Item> digDeeperItems  = new List <Item>();

            //first get items related to me...
            MultilistField related = Sitecore.Context.Item.Fields["Prerequisite Articles"];

            if (related != null)
            {
                foreach (Item i in related.GetItems())
                {
                    if (SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                    {
                        backgroundItems.Add(i);
                    }
                }
            }

            if (backgroundItems.Count > 0)
            {
                backgroundItems.Sort(new ItemSorterByTitle());
                rptPrereq.DataSource = backgroundItems;
                rptPrereq.DataBind();
            }

            //now get items I am related to
            foreach (Item i in Sitecore.Context.Database.SelectItems(SiteConfiguration.GetFurtherReadingArticlesQuery(Sitecore.Context.Item.ID.ToString())))
            {
                if (SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                {
                    digDeeperItems.Add(i);
                }
            }

            if (digDeeperItems.Count > 0)
            {
                digDeeperItems.Sort(new ItemSorterByTitle());
                rptAdditional.DataSource = digDeeperItems;
                rptAdditional.DataBind();
            }
        }
Пример #15
0
        private void LoadMenu()
        {
            Item presentation = SiteConfiguration.GetPresentationSettingsItem();

            if (presentation != null && presentation["Main Menu Type"] == "Inverse")
            {
                navbar.Attributes.Add("class", "navbar navbar-inverse");
            }

            // Set the page logo
            if (presentation["Logo Location"] == "Navigation Bar")
            {
                Logo.Item             = presentation;
                BrandLink.CssClass    = "brand logobrand";
                BrandLink.NavigateUrl = LinkManager.GetItemUrl(SiteConfiguration.GetHomeItem());
            }
            else
            {
                BrandLink.Text        = GetDictionaryText("navigate");
                BrandLink.NavigateUrl = "#";
                Logo.Visible          = false;
            }


            HomeItem = SiteConfiguration.GetHomeItem();
            List <Item> nodes = new List <Item>();

            if (HomeItem["Show Item In Menu"] == "1")
            {
                nodes.Add(HomeItem);
            }
            foreach (Item i in HomeItem.Children)
            {
                if (SiteConfiguration.DoesItemExistInCurrentLanguage(i) && i["Show Item In Menu"] == "1")
                {
                    nodes.Add(i);
                }
            }
            rptDropDownMenu.DataSource = nodes;
            rptDropDownMenu.DataBind();
        }
Пример #16
0
        private void Page_Load(object sender, EventArgs e)
        {
            Sitecore.Diagnostics.Tracer.Info("Footer Navigation - Page Load");
            Sitecore.Diagnostics.Profiler.StartOperation("Footer Navigation - Page Load");

            Item        baseItem = SiteConfiguration.GetFooterLinksItem();
            List <Item> nodes    = new List <Item>();

            foreach (Item footerLink in baseItem.Children)
            {
                Item i = Sitecore.Context.Database.GetItem(footerLink["Top Level Item"]);
                if (i != null && SiteConfiguration.DoesItemExistInCurrentLanguage(i))
                {
                    nodes.Add(i);
                }
            }

            rptMenu.DataSource = nodes;
            rptMenu.DataBind();

            Sitecore.Diagnostics.Profiler.EndOperation("Footer Navigation - Page Load");
        }
        public void LoadMenuItems()
        {
            menuItems = new List <MenuItem>();

            Item homeItem = LaunchSitecore.Configuration.SiteConfiguration.GetHomeItem();

            if (homeItem != null)
            {
                if (homeItem["Show Item in Menu"] == "1")
                {
                    menuItems.Add(new MenuItem(homeItem));
                }
                foreach (Item item in homeItem.GetChildren().Where(x => x["Show Item in Menu"].Equals("1") && SiteConfiguration.DoesItemExistInCurrentLanguage(x)))
                {
                    menuItems.Add(new MenuItem(item));
                }
            }
        }
Пример #18
0
        public PartialViewResult MainMenu()
        {
            var menuItems = new List <MenuItem>();

            Item homeItem = SiteConfiguration.GetHomeItem();

            if (homeItem != null)
            {
                if (homeItem["Show Item in Menu"] == "1")
                {
                    menuItems.Add(new MenuItem(homeItem));
                }
                foreach (Item item in homeItem.GetChildren().Where(x => x["Show Item in Menu"].Equals("1") && SiteConfiguration.DoesItemExistInCurrentLanguage(x)))
                {
                    menuItems.Add(new MenuItem(item));
                }
            }
            return(PartialView(menuItems));
        }
        public ActionResult QueriedList()
        {
            if (IsDataSourceItemNull)
            {
                return(null);
            }

            IEnumerable <SimpleItem> items   = DataSourceItems.Select(x => new SimpleItem(x)).Where(x => SiteConfiguration.DoesItemExistInCurrentLanguage(x.Item));
            SimpleItemList           results = new SimpleItemList(DataSourceItem["Title"], items);

            return(!items.IsNullOrEmpty() ? View(results) : ShowListIsEmptyPageEditorAlert());
        }
        public ActionResult IconAndTitleListForQuery()
        {
            /* Run the query and show the same view as IconAndTitleList */
            IEnumerable <SimpleItem> items = DataSourceItems.Select(x => new SimpleItem(x)).Where(x => SiteConfiguration.DoesItemExistInCurrentLanguage(x.Item));

            return(!items.IsNullOrEmpty() ? View("IconAndTitleList", items) : ShowListIsEmptyPageEditorAlert());
        }
        public ActionResult Carousel()
        {
            /* Use the base class to get the results of the query */
            IEnumerable <CarouselItem> items = DataSourceItems.Select(x => new CarouselItem(x)).Where(x => SiteConfiguration.DoesItemExistInCurrentLanguage(x.Item));

            return(!items.IsNullOrEmpty() ? View(items) : ShowListIsEmptyPageEditorAlert());
        }