コード例 #1
0
        public ActionResult RenderFeatured()
        {
            List <FeaturedItem> model         = new List <FeaturedItem>();
            IPublishedContent   homePage      = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault();
            ArchetypeModel      featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems");
            bool featuredItemsVisible         = (bool)homePage.GetPropertyValue("visible");

            if (featuredItemsVisible)
            {
                foreach (ArchetypeFieldsetModel fieldSet in featuredItems)
                {
                    var    mediaItem = fieldSet.GetValue <IPublishedContent>("image");
                    string imageUrl  = mediaItem.Url;

                    var pageId = fieldSet.GetValue <IPublishedContent>("page");
                    IPublishedContent linkedToPage = Umbraco.TypedContent(pageId.Id);
                    string            linkUrl      = linkedToPage.Url;
                    model.Add(new FeaturedItem(fieldSet.GetValue <string>("name"), fieldSet.GetValue <string>("category"), imageUrl, linkUrl));
                }
                return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model));
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");

            string title        = homePage.GetPropertyValue <string>("testimonialsTitle");
            string introduction = homePage.GetPropertyValue("testimonialsIntro").ToString();

            List <Testimonial> testimonials     = new List <Testimonial>();
            ArchetypeModel     testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialsList");

            if (testimonialsList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialsList.Take(2))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");

                    testimonials.Add(new Testimonial(name, quote));
                }
            }

            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView(PartialViewPath("_Testimonials"), model));
        }
コード例 #3
0
        public ActionResult RenderPostList(int maxNumberOfItems)
        {
            List <BlogPreview> model = new List <BlogPreview>();

            // get to the home page
            IPublishedContent blogPage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "blog").FirstOrDefault();

            // get all those fieldsets and put them in featured items

            foreach (IPublishedContent page in blogPage.Children.OrderByDescending(x => x.UpdateDate).Take(maxNumberOfItems))
            {
                var imageId   = page.GetPropertyValue <int>("articleimage");
                var mediaItem = Umbraco.Media(imageId);

                model.Add(new BlogPreview()
                {
                    Name         = page.Name,
                    Introduction = page.GetPropertyValue <string>("articleintro"),
                    ImageUrl     = mediaItem.Url,
                    LinkUrl      = page.Url
                });
            }

            return(PartialView(PARTIAL_VIEW_FOLDER + "_PostList.cshtml", model));
        }
コード例 #4
0
        public ActionResult RenderPostList(int numberOfItems)
        {
            List <BlogPostList> model    = new List <BlogPostList>();
            IPublishedContent   blogPage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "blog").FirstOrDefault();

            foreach (IPublishedContent page in blogPage.Children.OrderByDescending(x => x.UpdateDate).Take(numberOfItems))
            {
                //string name = page.GetPropertyValue<string>("title") or:

                string name         = page.Name;
                string introduction = page.GetPropertyValue <string>("articleIntro");

                //imageUrl
                int imageId = page.GetPropertyValue <int>("articleImage");
                //gets the value of media picker
                var    mediaItem = Umbraco.Media(imageId);
                string imageUrl  = mediaItem.Url;

                //linkUrl
                string linkUrl = page.Url;


                model.Add(new BlogPostList(name, introduction, imageUrl, linkUrl));
            }
            return(PartialView("~/Views/Partials/Blog/_PostList.cshtml", model));
        }
コード例 #5
0
        public ActionResult RenderTestimonials()
        {
            // render blog, get the home page
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");

            // gets these two properties on the home page
            string title = homePage.GetPropertyValue <string>("testimonialsTitle");
            // comes as HTML
            string introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString();


            // get testimonials from Umbraco
            List <Testimonial> testimonials = new List <Testimonial>();

            //populate the list we need to get the value
            ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");
                    testimonials.Add(new Testimonial(quote, name));
                }
            }

            // pass testimonials to Testimonials model
            //it has created the model
            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model));
        }
コード例 #6
0
        // GET: Master
        protected override ViewResult View(IView view, object model)
        {
            var rootNode      = CurrentPage.AncestorOrSelf(1);
            var currentMember = Members.GetCurrentMember();
            var children      = MenuItemMapper.Map <MenuItemModel>(rootNode.Children, CurrentPage, Umbraco).ToList();

            var global = new GlobalModel();

            global.MenuItems = new MenuItemModel()
            {
                Children = children, Url = rootNode.Url, Name = rootNode.Name
            };
            global.MemberLogin = new MemberLoginModel();
            global.IsLoggedIn  = false;
            if (currentMember != null)
            {
                global.IsLoggedIn  = true;
                global.MemberLogin = new MemberLoginModel()
                {
                    Username = currentMember.Name
                };
            }
            global.LoginPage = CurrentPage.Id == 1092 ? true : false;
            ViewBag.Global   = global;

            return(base.View(view, model));
        }
コード例 #7
0
        public ActionResult RenderPostList(int numberOfItems)
        {
            List <BlogPreview> model    = new List <BlogPreview>();
            IPublishedContent  homePage = CurrentPage.AncestorOrSelf("home");
            IPublishedContent  blogPage = homePage.Children.Where(x => x.DocumentTypeAlias == "blog").FirstOrDefault();

            //code to get the current page using helper
            //UmbracoHelper umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
            //IPublishedContent blogPage = CurrentPage.AncestorOrSelf("blog");
            //IPublishedContent blogPage = Umbraco.AssignedContentItem.AncestorOrSelf("blog");

            if (blogPage != null)
            {
                foreach (IPublishedContent page in blogPage.Children.OrderByDescending(x => x.UpdateDate).Take(numberOfItems))
                {
                    var imageId = page.GetPropertyValue <string>("articleImage");

                    var mediaItem = Umbraco.Media(imageId);
                    //page.Url is alink to the article/child of blog
                    model.Add(new BlogPreview(page.Name, page.GetPropertyValue <string>("articleIntro"), mediaItem.Url, page.Url));
                }
            }

            return(PartialView("~/Views/Partials/Blog/_PostList.cshtml", model));
        }
コード例 #8
0
        public ActionResult RenderFeatured()
        {
            // create a model object which is a list of featured items
            List <FeaturedItem> model = new List <FeaturedItem>();

            // goes to homePage, goes up the tree and down to find home, first instance
            IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault();
            // you could use this: IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");
            // gets featuredItems property as an Archetype Model
            ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems");

            // loops through the Archetype model, through fieldsets there to get name, cat etc
            foreach (ArchetypeFieldsetModel fieldset in featuredItems)
            {
                string imageUrl  = "";
                int    imageId   = fieldset.GetValue <int>("image");
                var    mediaItem = Umbraco.Media(imageId);
                imageUrl = mediaItem.Url;
                int pageId = fieldset.GetValue <int>("page");
                IPublishedContent linkedToPage = Umbraco.TypedContent(pageId);
                string            linkUrl      = linkedToPage.Url;
                // pass them through here
                model.Add(new FeaturedItem(fieldset.GetValue <string>("name"), fieldset.GetValue <string>("category"), imageUrl, linkUrl));
            }
            return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model));
        }
コード例 #9
0
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage     = CurrentPage.AncestorOrSelf("home");
            string            title        = homePage.GetPropertyValue <string>("testimonialsTitle");
            string            introduction = homePage.GetPropertyValue("testimonialsIntroduction").ToString();

            List <Testimonial> testimonials = new List <Testimonial>();

            // get the testimonialList from Umbraco, type archetype
            ArchetypeModel testimonialList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialList != null)
            {
                foreach (ArchetypeFieldsetModel testimonial in testimonialList.Take(MAXIMUM_TESTIMONIALS))
                {
                    string name  = testimonial.GetValue <string>("name");
                    string quote = testimonial.GetValue <string>("quote");
                    testimonials.Add(new Testimonial(quote, name));
                }
            }

            Testimonials model = new Testimonials(title, introduction, testimonials);

            return(PartialView("~/Views/Partials/Home/_Testimonials.cshtml", model));
        }
コード例 #10
0
        // GET: Home
        public ActionResult RenderFeatured()
        {
            var model = new List <FeaturedItem>();

            IPublishedContent home = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault();

            ArchetypeModel featuredItems = home.GetPropertyValue <ArchetypeModel>("featuredItems");

            foreach (ArchetypeFieldsetModel fieldset in featuredItems)
            {
                //Media Picker
                int    imageId   = fieldset.GetValue <int>("image");
                var    mediaItem = Umbraco.Media(imageId);
                string imageUrl  = mediaItem.Url;

                //Content Picker
                int pageId = fieldset.GetValue <int>("page");
                IPublishedContent linkedToPage = Umbraco.TypedContent(pageId);
                string            linkUrl      = linkedToPage.Url;

                //Textstring
                var name = fieldset.GetValue <string>("name");

                model.Add(new FeaturedItem(name, fieldset.GetValue("category"), imageUrl, linkUrl));
            }


            return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model));
        }
コード例 #11
0
        public ActionResult RenderNewsList(int itemsToShow)
        {
            List <NewsPreviewModel> model = new List <NewsPreviewModel>();
            //IPublishedContent newsPage = CurrentPage.AncestorsOrSelf("newsList").FirstOrDefault();
            IPublishedContent newsPage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "newsList").FirstOrDefault();

            if (newsPage != null && newsPage.Children.Any())
            {
                foreach (IPublishedContent page in newsPage.Children.OrderByDescending(y => y.GetPropertyValue <DateTime>("articleDate")).Take(itemsToShow))
                {
                    string title = page.GetPropertyValue <string>("articleTitle");
                    string intro = page.GetPropertyValue <string>("articleIntro");

                    int    imageId   = page.GetPropertyValue <int>("articleImage");
                    var    mediaItem = Umbraco.Media(imageId);
                    string imageUrl  = mediaItem.Url;

                    string linkUrl = page.Url;

                    //string articleDate = umbraco.library.FormatDateTime(page.GetPropertyValue("articleDate").ToString(), "dd-MM-yyyy");
                    string articleDate = page.GetPropertyValue <string>("articleDate");

                    model.Add(new NewsPreviewModel(title, intro, imageUrl, linkUrl, articleDate));
                }
            }
            return(PartialView(GetPathView("_Spotlight"), model));
        }
コード例 #12
0
        //
        // GET: /Master/

        protected override ViewResult View(string viewName, string masterName, object model)
        {
            //Move all "Global content" into the viewbag - it shouldnt be accessible in the model

            var frontPage = CurrentPage.AncestorOrSelf(1);

            var global = new GlobalModel();

            global.MainMenu = NavigationItemMapper.Map <NavigationItem>(frontPage, CurrentPage);
            ViewBag.Global  = global;

            /*
             * global.isFrontpage = CurrentPage.Id == rootNode.Id;
             *          global.GoogleAnalytics = GoogleAnalyticsMapper.Map<GoogleAnalyticsModel>(CurrentPage, Umbraco);
             *          global.Breadcrumb = NavigationItemMapper.Map(new List<NavigationItemModel>(), CurrentPage.AncestorsOrSelf(),
             *                  CurrentPage, Umbraco);
             *          global.TopMenu = NavigationItemMapper.Map(new List<NavigationItemModel>(), CurrentPage.AncestorsOrSelf(1),
             *                  CurrentPage, Umbraco);
             *          global.InShopContext = ShopHelper.InShopContext(CurrentPage);
             *          global.Seo = SeoMapper.Map<SeoModel>(CurrentPage, global.InShopContext, Umbraco);
             *          SetLanguageDropdown(global, rootNode);
             *          global.SocialMetaData = GetSocialMetaData(global, CurrentPage, rootNode);
             *          ViewBag.Global = global;
             */

            return(base.View(viewName, masterName, model));
        }
コード例 #13
0
        public ActionResult RenderFeatured()
        {
            List <FeaturedItem> model = new List <FeaturedItem>();

            // get to the home page
            IPublishedContent homePage      = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault();
            ArchetypeModel    featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems");

            // get all those fieldsets and put them in featured items


            // https://github.com/kgiszewski/Archetype/issues/413
            foreach (ArchetypeFieldsetModel fsm in featuredItems)
            {
                var    mediaItem = fsm.GetValue <IPublishedContent>("image");
                string imageUrl  = mediaItem.Url;

                var    linkedPage = fsm.GetValue <IPublishedContent>("page");
                string pageUrl    = linkedPage.Url;

                model.Add(new FeaturedItem()
                {
                    Name     = fsm.GetValue <string>("name"),
                    Category = fsm.GetValue <string>("category"),
                    ImageUrl = imageUrl,
                    LinkUrl  = pageUrl
                });
            }

            return(PartialView(PARTIAL_VIEW_FOLDER + "_Featured.cshtml", model));
        }
コード例 #14
0
        public ActionResult RenderMetaData()
        {
            SEO model = new SEO();

            IPublishedContent homePage      = CurrentPage.AncestorOrSelf("home");
            string            domainAddress = homePage.UrlWithDomain();


            //populate title or page name
            string title = CurrentPage.GetPropertyValue <string>("title");

            model.Title       = !string.IsNullOrEmpty(title) ? title : CurrentPage.Name;
            model.Description = CurrentPage.HasProperty("description") ? CurrentPage.GetPropertyValue <string>("description") : null;
            //for keyword we can use string, comma separated values
            model.Keywords = CurrentPage.HasProperty("keywords") ? CurrentPage.GetPropertyValue <string>("keywords") : null;

            if (CurrentPage.HasProperty("socialShareImage"))
            {
                int mediaId   = CurrentPage.GetPropertyValue <int>("socialShareImage");
                var mediaItem = Umbraco.Media(mediaId);
                model.ImageUrl = domainAddress.TrimEnd('/') + mediaItem.Url;
            }

            model.Url = CurrentPage.UrlWithDomain();


            return(PartialView("~/Views/Partials/SiteLayout/_MetaData.cshtml", model));
        }
コード例 #15
0
        public ActionResult RenderPostList(int numberOfItems)
        {
            List <BlogPreview> model = new List <BlogPreview>();

            IPublishedContent blogPage = CurrentPage.AncestorOrSelf().DescendantsOrSelf().Where(x => x.ContentType.Alias == "blogEntries").FirstOrDefault(); //Remove number parameter in AncestorOrSelf() so it can search throug all in the navigation menu

            var pageNumber = 1;

            var pageSize = numberOfItems;

            var pageOfArticles = blogPage.Children.Skip((pageNumber - 1) * pageSize).Take(pageSize);

            var totalItemCount = blogPage.Children.Count();

            var pageCount = totalItemCount > 0 ? Math.Ceiling((double)totalItemCount / pageSize) : 1;


            foreach (IPublishedContent page in blogPage.Children.OrderByDescending(x => x.UpdateDate).Take(numberOfItems))
            {
                var pageName      = page.Name;
                var intro         = page.Value <string>("ArticleIntro");
                var imageUrl      = page.Value <IPublishedContent>("ArticleImage").Url;
                var pageUrl       = page.Url;
                var creator       = page.CreatorName;
                var publishedDate = page.CreateDate.ToString("MMMM dd, yyyy");

                model.Add(new BlogPreview(pageName, intro, imageUrl, pageUrl, creator, publishedDate));
            }

            return(PartialView(PARTIAL_VIEW_FOLDER + "_PostList.cshtml", model));
        }
コード例 #16
0
        public ActionResult RenderFeatured()
        {
            List <FeaturedItem> model = new List <FeaturedItem>();
            //IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.DocumentTypeAlias == "home").FirstOrDefault();
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");

            //Get property from the homepage
            //From ArchetypeMode model get all the fieldsets and put them into FeaturedItem class
            ArchetypeModel featuredItems = homePage.GetPropertyValue <ArchetypeModel>("featuredItems");

            foreach (ArchetypeFieldsetModel fieldset in featuredItems)
            {
                string name     = fieldset.GetValue <string>("name");
                string category = fieldset.GetValue <string>("category");

                //imageUrl
                int imageId = fieldset.GetValue <int>("image");
                //gets the value of media picker
                var    mediaItem = Umbraco.Media(imageId);
                string imageUrl  = mediaItem.Url;


                //linkUrl
                int pageId                = fieldset.GetValue <int>("page");
                IPublishedContent page    = Umbraco.TypedContent(pageId);
                string            linkUrl = page.Url;


                model.Add(new FeaturedItem(name, category, imageUrl, linkUrl));
            }
            return(PartialView(PartialViewPath("_Featured"), model));
        }
コード例 #17
0
        //public LatestBlogPost GetLatestBlogPostModel()
        //{
        //    IPublishedContent page = CurrentPage.AncestorOrSelf("home");
        //    LatestBlogPost model = new LatestBlogPost()
        //    {
        //        Title = page.GetPropertyValue<string>("latestBlogPostsTitle"),
        //        Introduction = page.GetPropertyValue<string>("latestBlogPostsIntroduction")
        //    };
        //    return model;
        //}

        public ActionResult RenderTestimonials()
        {
            const string      HOME_PAGE_DOC_TYPE_ALIAS = "home";
            IPublishedContent page            = CurrentPage.AncestorOrSelf(HOME_PAGE_DOC_TYPE_ALIAS);
            ArchetypeModel    testimonialList = page.GetPropertyValue <ArchetypeModel>("testimonialList");

            List <TestimonialModel> testimonials = new List <TestimonialModel>();

            if (testimonials != null || testimonials.Count > 0)
            {
                foreach (ArchetypeFieldsetModel fieldSet in testimonialList.Take(MAX_TESTIMONIAL))
                {
                    testimonials.Add(new TestimonialModel()
                    {
                        Name  = fieldSet.GetValue <string>("name"),
                        Quote = fieldSet.GetValue <string>("quote")
                    });
                }
            }


            TestimonialsModel model = new TestimonialsModel()
            {
                Title        = page.GetPropertyValue <string>("testimonialsTitle"),
                Introduction = page.GetPropertyValue <string>("testimonialsIntroduction"),
                Testimonials = testimonials
            };

            return(PartialView(PartialViewPath("_Testimonials"), model));
        }
コード例 #18
0
        public ActionResult HandleLogin([Bind(Prefix = "loginModel")] LoginModel model)
        {
            if (ModelState.IsValid == false)
            {
                return(CurrentUmbracoPage());
            }

            if (Members.Login(model.Username, model.Password) == false)
            {
                //don't add a field level error, just model level
                ModelState.AddModelError("loginModel", "Invalid username or password");
                return(CurrentUmbracoPage());
            }

            TempData["LoginSuccess"] = true;

            //if there is a specified path to redirect to then use it
            if (model.RedirectUrl.IsNullOrWhiteSpace() == false)
            {
                // validate the redirect URL
                // if it's not a local URL we'll redirect to the root of the current site
                return(Redirect(Url.IsLocalUrl(model.RedirectUrl)
                    ? model.RedirectUrl
                    : CurrentPage.AncestorOrSelf(1).Url()));
            }

            //redirect to current page by default

            return(RedirectToCurrentUmbracoPage());
        }
コード例 #19
0
        //Verify Email
        /// <summary>
        /// Renders the Verify Email
        /// @Html.Action("RenderVerifyEmail","AuthSurface");
        /// </summary>
        /// <returns></returns>
        public ActionResult RenderVerifyEmail(string verifyGUID)
        {
            //Homepage node
            var home = CurrentPage.AncestorOrSelf("CWS-Home");

            //Auto binds and gets guid from the querystring
            Member findMember = Member.GetAllAsList().SingleOrDefault(x => x.getProperty("emailVerifyGUID").Value.ToString() == verifyGUID);

            //Ensure we find a member with the verifyGUID
            if (findMember != null)
            {
                //We got the member, so let's update the verify email checkbox
                findMember.getProperty("hasVerifiedEmail").Value = true;

                //Save the member
                findMember.Save();
            }
            else
            {
                //Update success flag (in a TempData key)
                TempData["IsSuccessful"] = false;

                //Couldn't find them - most likely invalid GUID
                return(PartialView("VerifyEmail"));
            }

            //Update success flag (in a TempData key)
            TempData["IsSuccessful"] = true;

            //All sorted let's redirect to root/homepage
            return(PartialView("VerifyEmail"));
        }
コード例 #20
0
        private void CreateTour()
        {
            int               userId   = 0;
            IContentService   cs       = Services.ContentService;
            IPublishedContent home     = Umbraco.AssignedContentItem.AncestorOrSelf("home");
            var               homePage = CurrentPage.AncestorOrSelf("home");
            //var MyContent = Umbraco.Content(1111).Url();
            var umbesEntityService = Services.EntityService;
            var sdsd = umbesEntityService.GetKey(homePage.Id, UmbracoObjectTypes.Document);
            var id   = "umb://document/" + sdsd;
            //Udi udi = Udi.Parse(id) ;

            //if (Udi.TryParse(id, out udi))
            //{
            //    return udi.ToPublishedContent();
            //}

            //IPublishedContent gContent = umbracoHelper.TypedContent(1111);
            var gid = new Guid("0b949542-2625-4a11-9516-5c6446b26eca");
            //var content = cs.Create("Tour2", new Guid(sdsd.ToString()), "Tour", userId);
            var content = cs.Create("Tour3", gid, "Tour", userId);

            // Umbraco.
            //content.SetValue("Name", "Test121");
            content.SetValue("HeroTitle", "Test121");
            content.SetValue("HeroDescription", "Hike one of the most beautiful mountain landscapes in the world. Italy’s dramatic rocky rooftop, the Dolomites offer spectacular views and lovely surroundings, especially on this spring tour. You will enjoy the wild Alpine meadows, snow-tipped peaks and cobblestone mountain villages. We will take scenic paths from Cortina d’ Ampezzo to Alta Badia and learn about the fascinating history of the region along the way.");
            cs.SaveAndPublish(content, "*", -1, true);
        }
コード例 #21
0
        public ActionResult Search(string query)
        {
            var searchResPage = CurrentPage.AncestorOrSelf(1).FirstChild <SearchResults>();

            if (ExamineManager.Instance.TryGetIndex("ArticleIndex", out var index))
            {
                var searcher      = index.GetSearcher();
                var searchTerms   = SplitSearchTerms(query);
                var querySearcher = searcher.CreateQuery("content", BooleanOperation.Or).NodeTypeAlias("article");
                foreach (var examineValue in searchTerms)
                {
                    querySearcher.And().Field("nodeName", examineValue);
                }
                var results = querySearcher.Not().Field("umbracoNaviHide", "1").Execute();
                if (results.Any())
                {
                    var total = results.TotalItemCount;
                    var res   = Umbraco.Content(results.Select(x => x.Id)).ToList();
                    TempData["Result"] = res;
                    return(RedirectToUmbracoPage(searchResPage));
                }
            }

            return(CurrentUmbracoPage());
        }
コード例 #22
0
        public ActionResult RenderTestimonials()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");
            string            title    = homePage.GetPropertyValue <string>("testimonialsTitle");
            string            intro    = homePage.GetPropertyValue("testimonialsIntroduction").ToString(); // don't want the html

            List <TestimonialModel> testimonials     = new List <TestimonialModel>();
            ArchetypeModel          testimonialsList = homePage.GetPropertyValue <ArchetypeModel>("testimonialList");

            if (testimonialsList != null)
            {
                foreach (ArchetypeFieldsetModel fsm in testimonialsList.Take(3))
                {
                    string name  = fsm.GetValue <string>("name");
                    string quote = fsm.GetValue <string>("quote");
                    testimonials.Add(new TestimonialModel()
                    {
                        Name  = name,
                        Quote = quote
                    });
                }
            }

            TestimonialsModel model = new TestimonialsModel()
            {
                Title        = title,
                Introduction = intro,
                Testimonials = testimonials
            };

            return(PartialView(PARTIAL_VIEW_FOLDER + "_Testimonials.cshtml", model));
        }
コード例 #23
0
        public ActionResult LanguageSelector()
        {
            var countryPage = CurrentPage.AncestorOrSelf <CountryPage>();

            var model = new LanguageSelectorViewModel
            {
                Languages = countryPage
                            .Children <LanguagePage>()
                            .OrderBy(l => l.LanguageName),

                Current = CurrentPage.AncestorOrSelf <LanguagePage>()
            };

            if (model.Languages.Count() < 2)
            {
                return(Content(string.Empty));
            }

            // Here we are using the home page url,
            // not the language page url

            foreach (var language in model.Languages)
            {
                language.HomePageUrl = language.FirstChild <HomePage>().Url;
            }

            return(PartialView("LanguageSelector", model));
        }
        public ActionResult Sitemap()
        {
            var model = GetModel <SitemapModel>();

            model.SitemapItems = GetSitemapItems(CurrentPage.AncestorOrSelf(1));
            return(CurrentTemplate(model));
        }
コード例 #25
0
        public ActionResult RenderWeAreAbout()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf("home");
            string title = homePage.GetPropertyValue<string>("weAreAboutTitle");
            string bodyText = homePage.GetPropertyValue("weAreAboutBodyText").ToString();

            WeAreAboutModel model = new WeAreAboutModel(title, bodyText);
            return PartialView(PartialViewPath(_weAreAboutPartialViewName), model);
        }
コード例 #26
0
        public ActionResult SubmitLogout()
        {
            TempData.Clear();
            Session.Clear();
            FormsAuthentication.SignOut();
            IPublishedContent homePage = CurrentPage.AncestorOrSelf(1);

            return(RedirectToUmbracoPage(homePage.Id));
        }
コード例 #27
0
        private List <CategoryListItem> GetCategoryModelFromDatabase()
        {
            IPublishedContent       homePage = CurrentPage.AncestorOrSelf(1).DescendantsOrSelf().Where(x => x.ContentType.Alias == "homepage").FirstOrDefault();
            List <CategoryListItem> nav      = new List <CategoryListItem>();

            nav.Add(new CategoryListItem(new CategoryLink(homePage.Url, homePage.Name)));
            nav.AddRange(GetChildCategoryList(homePage));
            return(nav);
        }
コード例 #28
0
        /// <summary>
        /// Finds the home page and gets the navigation structure based on it and it's children
        /// </summary>
        /// <returns>A List of NavigationListItems, representing the structure of the site.</returns>
        private List <NavigationListItem> GetNavigationModelFromDatabase()
        {
            IPublishedContent         homePage = CurrentPage.AncestorOrSelf("home");
            List <NavigationListItem> nav      = new List <NavigationListItem>();

            nav.Add(new NavigationListItem(new NavigationLink(homePage.Url, homePage.Name)));
            nav.AddRange(GetChildNavigationList(homePage));
            return(nav);
        }
コード例 #29
0
        protected void MapBaseProperties(BaseViewModel model)
        {
            var homePage = CurrentPage.AncestorOrSelf(1);

            FooterViewModel footer = new FooterViewModel();

            Mapper.Map(homePage, footer);
            model.Footer = footer;
        }
コード例 #30
0
        private List <NavigationListItem> GetNavigationModelFromDatabase()
        {
            IPublishedContent homePage = CurrentPage.AncestorOrSelf(1).DescendantOrSelf().AsEnumerableOfOne().FirstOrDefault(x => x.IsDocumentType("HomePage"));

            List <NavigationListItem> nav = new List <NavigationListItem>();

            nav.Add(new NavigationListItem(new NavigationLink(homePage.Url, homePage.Name)));
            nav.AddRange(GetChildNavigationList(homePage));
            return(nav);
        }