-
-
Notifications
You must be signed in to change notification settings - Fork 107
Creating a theme
The easiest way to create a theme is to choose an existing theme with the feature set that you require and copy/paste its folder. Then to name your theme, just name the copied folder with the theme name of your choice.
All of Articulate theme parts are strongly typed. The underlying model that controls all of the main views is:
Articulate.Models.IMasterModel
which inherits from IPublishedContent
so you still get all of those features as well.
There are quite a few Articulate helper methods that rely on Articulate.Models.IMasterModel
so it's very easy to just pass the current model for pages into these helper methods.
Here are the models for each main view, each of which implements Articulate.Models.IMasterModel
and also inherits from IPublishedContent
- Post.cshtml =
Articulate.Models.PostModel
- List.cshtml =
Articulate.Models.ListModel
- Tags.cshtml =
Articulate.Models.TagListModel
These are the properties of IMasterModel:
string Theme { get; }
IPublishedContent RootBlogNode { get; }
IPublishedContent BlogArchiveNode { get; }
string Name { get; }
string BlogTitle { get; }
string BlogDescription { get; }
string BlogLogo { get; }
string BlogBanner { get; }
int PageSize { get; }
string DisqusShortName { get; }
string CustomRssFeed { get; }
These are the properties of PostModel:
IEnumerable<string> Tags {get;}
IEnumerable<string> Categories {get;}
bool EnableComments {get;}
AuthorModel Author {get;}
string Excerpt {get;}
DateTime PublishedDate {get;}
IHtmlString Body {get;}
These are the properties of ListModel:
PagerModel Pages {get;}
These are the properties of TagListModel:
PostTagCollection Tags {get;}
Themes generally use partial views quite a lot and when rendering a partial view from a theme you need to use a special helper method to do this so that MVC knows where to look for the view:
@Html.ThemedPartial(Model, "CommentsDisqus")
And like the normal HtmlHelper.Partial method, this method will accept all of the other overloads too.
Articulate comes bundled with all sorts of handy helper methods.
//Handy method to manage loading, bundling & minifying assets:
HtmlHelper RequiresThemedCss(this HtmlHelper html, IMasterModel model, string filePath)
HtmlHelper RequiresThemedJs(this HtmlHelper html, IMasterModel model, string filePath)
HtmlHelper RequiresThemedCssFolder(this HtmlHelper html, IMasterModel model)
HtmlHelper RequiresThemedJsFolder(this HtmlHelper html, IMasterModel model)
//Misc Articulate methods
IHtmlString RssFeed(this HtmlHelper html, IMasterModel model)
IHtmlString AdvertiseWeblogApi(this HtmlHelper html, IMasterModel model)
IHtmlString GoogleAnalyticsTracking(this HtmlHelper html, IMasterModel model)
//Used to render partial views in theme folders
IHtmlString ThemedPartial(this HtmlHelper html, IMasterModel model, string partialName, object viewModel, ViewDataDictionary viewData = null)
IHtmlString ThemedPartial(this HtmlHelper html, IMasterModel model, string partialName, ViewDataDictionary viewData = null)
//Handy tag methods
IHtmlString TagCloud(this HtmlHelper html, PostTagCollection model, decimal maxWeight, int maxResults)
HelperResult ListTags(this HtmlHelper html, PostModel model, Func<string, HelperResult> tagLink, string delimiter = ", ")
HelperResult ListCategories(this HtmlHelper html, PostModel model, Func<string, HelperResult> tagLink, string delimiter = ", ")
//Misc markup methods
HelperResult Table<T>(this HtmlHelper html, IEnumerable<T> collection, string[] headers, string[] cssClasses, params Func<T, HelperResult>[] cellTemplates) where T : class
These methods can be used to generate URLs for use in your views:
string ThemedAsset(this UrlHelper url, IMasterModel model, string relativeAssetPath)
string ArticulateRssUrl(this UrlHelper url, IMasterModel model)
string ArticulateTagRssUrl(this UrlHelper url, PostsByTagModel model)
string ArticulateSearchUrl(this UrlHelper url, IMasterModel model)
string ArticulateRootUrl(this UrlHelper url, IMasterModel model)
string ArticulateCategoriesUrl(this UrlHelper url, IMasterModel model)
string ArticulateTagsUrl(this UrlHelper url, IMasterModel model)
string ArticulateTagUrl(this UrlHelper url, IMasterModel model, string tag)
string ArticulateCategoryUrl(this UrlHelper url, IMasterModel model, string category)