Adding a logo
A logo image could be added to the site definition (as it's a global property).
Open Models/DemoSite.cs in the demo project and add the following lines:
[Property("Company logo")]
public virtual ImageProperty CompanyLogo { get; set; }
Open
Views/Shared/_Layout.cshtml and add this to render the image:
<a href="~/" class="navbar-brand" title="Demo project">
@Model.CurrentSite.CompanyLogo.ToHtml()
</a>
Adding meta data to all pages
A good pattern is to create a base page model with common properties, such as meta data, and let all page models inherit this model.
I'm attaching all the modified files to this post for convenience, but this is a quick walk trough:
Add a new model; Models/Pages/PageBase.cs:
namespace DemoSite.Models.Pages {
using KalikoCMS.Attributes;
using KalikoCMS.Core;
using KalikoCMS.PropertyType;
public class PageBase : CmsPage {
[Property("Meta description", TabGroup = "SEO")]
public virtual TextProperty MetaDescription { get; set; }
}
}
Update all pages to inherit the new page base instead of CmsPage:
...
public class ArticlePage : PageBase, IIndexable {
...
The view model needs to change to be based on the new page base model.
Models/ViewModels/IPageViewModel.cs:
public interface IPageViewModel<out T> where T : PageBase {
Models/ViewModels/PageViewModel.cs:
public class PageViewModel<T> : IPageViewModel<T> where T : PageBase {
Open Views/Shared/_Layout.cshtml and change the model and render the new meta property:
@using KalikoCMS.Configuration
@model DemoSite.Models.ViewModels.IPageViewModel<DemoSite.Models.Pages.PageBase>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>@Model.CurrentPage.PageName</title>
<meta name="description" content="@Model.CurrentPage.MetaDescription">
...
You now have the infrastructure to add further meta fields.
Hope that helps!