Example #1
0
 public void ChangeContext(int DocumentID)
 {
     httpContextRetriever.GetContext().Items["Kentico.PageBuilder.DataContext"] = new PageBuilderDataContext()
     {
         Options  = httpContext.HttpContext.Kentico().PageBuilder().Options,
         EditMode = false
     };
     pageDataContextInitializer.Initialize(DocumentID);
 }
Example #2
0
        public IActionResult Index()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            TreeNode page = _pagesRetriever.Retrieve <TreeNode>(query => query
                                                                .Path("/Home", PathTypeEnum.Single))
                            .FirstOrDefault();

            // Responds with the HTTP 404 error when the page is not found
            if (page == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            _pageDataContextInitializer.Initialize(page);

            var homeSource = HomeProvider.GetHome(Guid.Parse(Home.NodeGuidId), "en-US", "HouseRestaurant");

            var menus  = NavigationProvider.GetMenuItems();
            var dishes = DishProvider.GetDishCategories();

            var vm = new HomeViewModel()
            {
                Id          = homeSource.First().HomeID,
                Description = homeSource.First().Description,
                Title       = homeSource.First().Title,
                MenuItems   = menus,
                Dishes      = dishes
            };


            return(View(vm));
        }
        public async Task <IActionResult> Home()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            var jssHome = _pagesRetriever.Retrieve <TreeNode>(query => query.WithID(PageID)).FirstOrDefault();

            //var jssHome = pages.FirstOrDefault(e => DocumentURLProvider.GetAbsoluteUrl(e).ToLower().Contains("/myblog/jss/home"));

            // Responds with the HTTP 404 error when the page is not found
            if (jssHome == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            _pageDataContextInitializer.Initialize(jssHome);

            //var blogHomePage = _dataRetriever.Retrieve<BlogHome>().Page;
            //var id = blogHomePage.Fields.ID;
            //var title = blogHomePage.Fields.Title;

            var documentQueryHome = BlogHomeProvider.GetBlogHome(NodeGuid, "en-US", "BlogPost");
            var data = documentQueryHome.FirstOrDefault();

            return(View(new BlogHomeViewModel()
            {
                Title = data.BlogHomeTitle
            }));
        }
Example #4
0
        public async Task <ActionResult> Index(CancellationToken cancellationToken)
        {
            var pages = _pageRetriever.Retrieve <TreeNode>(query => query
                                                           .Path("/", PathTypeEnum.Children));

            var aboutUsPage = pages.FirstOrDefault(e => DocumentURLProvider.GetAbsoluteUrl(e).ToLower().Contains("/myblog/about"));

            _pageDataContextInitializer.Initialize(aboutUsPage);
            //var aboutUs = _dataRetriever.Retrieve<AboutUs>().Page;

            //var sideStories = await aboutUsRepository.GetSideStoriesAsync(aboutUs.NodeAliasPath, cancellationToken);

            //var reference = (await referenceRepository.GetReferencesAsync($"{aboutUs.NodeAliasPath}/References", cancellationToken, 1)).FirstOrDefault();
            var sideStories = new List <AboutUsSection> ();

            var documentQueryHome = AboutUsProvider.GetAboutUs(NodeGuid, "en-US", "BlogPost");
            var data = documentQueryHome.FirstOrDefault();

            AboutUsViewModel mode = new AboutUsViewModel()
            {
                ID    = data.AboutUsID,
                Title = data.AboutUsText,
                Desc  = data.AboutUsDesc
            };

            return(View(mode));
        }
    public static void ChangeContext(this HtmlHelper helper, TreeNode Document)
    {
        IHttpContextRetriever       httpContextRetriever       = DependencyResolver.Current.GetService <IHttpContextRetriever>();
        IPageDataContextInitializer pageDataContextInitializer = DependencyResolver.Current.GetService <IPageDataContextInitializer>();

        httpContextRetriever.GetContext().Items["Kentico.PageBuilder.DataContext"] = new PageBuilderDataContext()
        {
            Options  = HttpContext.Current.Kentico().PageBuilder().Options,
            EditMode = false
        };
        pageDataContextInitializer.Initialize(Document);
    }
Example #6
0
        public ActionResult Home()
        {
            // Retrieves a page from the Xperience database with the '/Home' node alias path
            TreeNode page = pagesRetriever.Retrieve <TreeNode>(query => query
                                                               .Path("/Home", PathTypeEnum.Single))
                            .FirstOrDefault();

            // Responds with the HTTP 404 error when the page is not found
            if (page == null)
            {
                return(NotFound());
            }

            // Initializes the page data context (and the page builder) using the retrieved page
            pageDataContextInitializer.Initialize(page);

            return(View());
        }