Tips and Tricks
Authentication:
Use this in razor file: "@if (Request.IsAuthenticated){}" to only show elements if authenticated
Make a SCE page have to login to access:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Byu.Fhss.Sce.Authorization;
using Byu.Fhss.Sce.PageManagement;
namespace NeuroScience.Controllers
{
[SCEAuthenticate]
public class AuthPageController : Controller
{
// GET: AuthPage
public ActionResult Index() { return View(); }
public ActionResult GraduateForms()
{
ScePage page = new ScePage();
page.UriName = "graduate-forms_";
return View("~/Plugins/SCE/PageLayouts/Landing-Page.cshtml", page);
} } }
List Manager:
@using Byu.Fhss.Sce.ListManager.ListSystem
SceList Events = SceListSystemManager.GetList("Events");
var EventList = Events.Rows or Events.Items;
//if Events.Items(new way)(Use Camel case or _ for naming column names)
EventList.Where(e => e.column_name == "1") //(example column_name could be: e.ID)
Tip to help users
//If you use the List manager throw in a link/button like the code bellow so user knows where to edit page
@if(Request.IsAuthenticated)
{
Mange Page Amount
}
Links:
When linking in the tiny mce editor make sure to use \ instead of / you'll have issues otherwise
Page Layouts:
If you add folder in the PageLayouts folder then it will not show up as a template in the user interface
Custom Homepage/Override SCE Routing
By default SCE routes are registered before the routes in your project. If you would like to set a custom, non-SCE page homepage (or any other page that would normally be routed as a SCE resoure) you need to register your custom routes before the areas are registered in Global.asax.cs.
By default that class looks something like this.
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
SCE routes are piacked up and registered in RegisterAllAreas(), but the routes in teh default RouteConfig.cs are not registered until two lines later. Since the router selects the first route that matches on the URL property, SCE routes are given priority.
In order to override SCE things, duplicate the ~/App_Start/RouteConfig.cs class and name it PreSceRoutes.cs (or something descriptive). Register your routes in that class and add a call to its RegisterRoutes method before the area registration like so.
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
PreSceRoutes.RegisterRoutes(RouteTable.Routes); // This line is the one you added.
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}