コード例 #1
0
        public async Task <IActionResult> Index(string pageKeyName, int moduleId, string moduleControl, string moduleAction)
        {
            if (string.IsNullOrEmpty(pageKeyName))
            {
                return(RedirectToAction("Index", "Home"));
            }

            PageInfo page = await _viewManager.GetPageByKeyAsync(pageKeyName, true);

            if (page is null)
            {
                return(NotFound());
            }

            TemplateInfo template = page.PageTemplate;

            //Get site parameters
            SiteConfigurationInfo siteConfiguration = await _parameterManager.GetSiteConfigurationAsync();

            // Set page title
            ViewBag.Title = string.IsNullOrEmpty(page.Title) ? siteConfiguration.Title : page.Title;

            // Set theme
            ViewBag.Theme = siteConfiguration.Theme ?? SiteConfiguration.DefaultTheme;

            // Set page SEO
            ViewBag.MetaDescription = string.IsNullOrEmpty(page.MetaDescription) ? siteConfiguration.Description : page.MetaDescription;
            ViewBag.MetaKeywords    = page.MetaKeywords;
            ViewBag.MetaRobot       = page.MetaRobot;

            ViewEngine viewEngine = new ViewEngine(page, _cacheEngine);

            // Create template model
            object model = viewEngine.CreateView(moduleControl, moduleId, moduleAction);

            // Home page style
            if (pageKeyName.ToLower() == "home")
            {
                ViewBag.IsHome = true;
            }

            return(View(template.KeyName, model));
        }
コード例 #2
0
        public async Task <IActionResult> Index(int pageID, string moduleControl = "")
        {
            if (pageID <= 0)
            {
                return(RedirectToAction("Index", "Home"));
            }

            PageInfo page = await _viewManager.GetPageAsync(pageID, true);

            if (page is null)
            {
                return(NotFound());
            }

            TemplateInfo template   = page.PageTemplate;
            ViewEngine   viewEngine = new ViewEngine(page, _cacheEngine);

            object model = viewEngine.CreateView(moduleControl, 0, null);

            return(View(template.KeyName, model));
        }
 public void SetInstanceFromViewResult(ViewResult viewResult)
 {
     Instance = ViewEngine.CreateView(viewResult.ViewName);
 }