Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save simoncowie/8bf25191ff55ac726f60 to your computer and use it in GitHub Desktop.
Save simoncowie/8bf25191ff55ac726f60 to your computer and use it in GitHub Desktop.
Sitefinity Feather widget for auto Page Titles

#Sitefinity Feather PageTitle widget

Sitefinity Feather widget for auto Page Titles.

TODO:

  • I'll update it at some point to make the enclosing tag configurable.
@model SitefinityWebApp.Mvc.Models.PageTitleModel
<h2>
@Html.Raw(Model.PageTitle)
</h2>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SitefinityWebApp.Mvc.Models;
using Telerik.Sitefinity.Modules.Pages;
using Telerik.Sitefinity.Mvc;
using Telerik.Sitefinity.Web;
namespace SitefinityWebApp.Mvc.Controllers
{
[ControllerToolboxItem(Name = "Page Title", Title = "Page Title", SectionName = "Page Widgets")]
public class PageTitleController : Controller
{
/// <summary>
/// This is the default Action.
/// </summary>
public ActionResult Index()
{
var model = new PageTitleModel();
if (SiteMapBase.GetCurrentProvider().CurrentNode != null)
{
model.PageTitle = new PageManager()
.GetPageNode(new Guid(SiteMapBase.GetCurrentProvider().CurrentNode.Key))
.Title;
}
else
{
model.PageTitle = "Page Title";
}
return View("Default", model);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace SitefinityWebApp.Mvc.Models
{
public class PageTitleModel
{
/// <summary>
/// The page's title
/// </summary>
public string PageTitle { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment