Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Im implementing Seo and following Paul Seal example https://codeshare.co.uk/blog/how-to-optimise-your-website-for-search-engines-seo-in-umbraco/
In the surfacecontroller I want to use the modelsbuilder instead of Currentpage
namespace FionaWhitfieldArt.Controllers { public class SiteLayoutController : SurfaceController { private string PartialViewPath(string name) { return $"~/Views/Partials/SiteLayout/{name}.cshtml"; } public ActionResult RenderMetaData() { MetaDataModel model = new MetaDataModel(); IPublishedContent homePage = CurrentPage.AncestorOrSelf("home"); string domainAddress = homePage.UrlWithDomain(); string title = CurrentPage.GetPropertyValue<string>("title"); model.Title = !string.IsNullOrEmpty(title) ? title : CurrentPage.Name; model.Description = CurrentPage.HasProperty("description") ? CurrentPage.GetPropertyValue<string>("description") : null; model.Keywords = CurrentPage.HasProperty("keywords") ? CurrentPage.GetPropertyValue<string>("keywords") : null; if(CurrentPage.HasProperty("socialShareImage")) { int mediaId = CurrentPage.GetPropertyValue<int>("socialShareImage"); var mediaItem = Umbraco.Media(mediaId); model.ImageUrl = $"{domainAddress.TrimEnd('/')}{mediaItem.Url}"; } model.Url = CurrentPage.UrlWithDomain(); return PartialView(PartialViewPath("_MetaData"), model); } } }
Many Thanks/Christina
Try,
var strongCurrentPage = CurrentPage as Whatever your type is ?
Regards
Ismail
Hi Ismail
many thanks /Christina
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How can I use Modelsbuilder in a surfacecontroller
Hi Im implementing Seo and following Paul Seal example https://codeshare.co.uk/blog/how-to-optimise-your-website-for-search-engines-seo-in-umbraco/
In the surfacecontroller I want to use the modelsbuilder instead of Currentpage
Many Thanks/Christina
Try,
var strongCurrentPage = CurrentPage as Whatever your type is ?
Regards
Ismail
Hi Ismail
many thanks /Christina
is working on a reply...