Skip to content

Instantly share code, notes, and snippets.

@ivaneftimov
Created July 12, 2016 16:08
Show Gist options
  • Select an option

  • Save ivaneftimov/41b385db3353960b201cf514ad48c4cf to your computer and use it in GitHub Desktop.

Select an option

Save ivaneftimov/41b385db3353960b201cf514ad48c4cf to your computer and use it in GitHub Desktop.
Resource class for the BreakingNews widget
// SitefinityWebapp\Mvc\Controllers\BreakingNewsController.cs
using SitefinityWebApp.Localization;
using SitefinityWebApp.Mvc.Models;
using SitefinityWebApp.Wrappers;
using System.Linq;
using System.Web.Mvc;
using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes;
using Telerik.Sitefinity.Modules.News;
using Telerik.Sitefinity.Mvc;
namespace SitefinityWebApp.Mvc.Controllers
{
[Localization(typeof(BreakingNewsResources))]
[ControllerToolboxItem(Title = "Breaking News", Name = "BreakingNews", SectionName = "CustomMvcWidgets")]
public class BreakingNewsController : Controller
{
public BreakingNewsController(INewsManagerWrapper newsManager)
{
this.newsManager = newsManager.GetManager();
}
public string Date { get; set; }
public string Message { get; set; }
public string BreakingNewsMessage { get; set; }
public string SelectedItem { get; set; }
public ActionResult Index()
{
var firstNewsItem = this.newsManager.GetNewsItems().FirstOrDefault();
BreakingNewsModel model = new BreakingNewsModel();
model.Message = firstNewsItem.Title;
return View(model);
}
private NewsManager newsManager;
}
}
// SitefinityWebApp\Localization\BreakingNewsResources.cs
using Telerik.Sitefinity.Localization;
namespace SitefinityWebApp.Localization
{
public class BreakingNewsResources : Resource
{
[ResourceEntry("StaticMessage", Value = "This is the static message", Description = "Static message on the BreakingNews view.", LastModified = "2016/07/12")]
public string StaticMessage { get; set; }
}
}
@* SitefinityWebapp\Mvc\Views\BreakingNews\Index.cshtml *@
@model SitefinityWebApp.Mvc.Models.BreakingNewsModel
@using Telerik.Sitefinity.Frontend.Mvc.Helpers
<p>
@Html.Resource("StaticMessage")
</p>
<marquee>
@Html.Raw(Model.Message)
</marquee>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment