Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rhett Lowson 2 posts 72 karma points
    Jun 21, 2017 @ 13:44
    Rhett Lowson
    0

    Using Vorto with Umazel to get language specific titles

    Hello, I am using the Umazel starter project and have done some customization already to use Vorto-wrapped objects to get multi-language support on some of the page properties that we want to use.

    There is one that I have not been able to find in order to override. In the PageMetas.cshtml file is the following line:

    <title>@currPage.GetPageBrowserTitle(settings)</title>
    

    I have been able to create overrides for most of the properties I need by editing the models files, but I don't see where this is looking to. As a result I get the following output in my HTML:

    <title>Our.Umbraco.Vorto.Models.VortoValue</title>
    

    If I knew what the GetPageBrowserTitle() was doing I might be able to resolve this problem.

  • Sotiris Filippidis 286 posts 1501 karma points
    Jun 21, 2017 @ 13:51
    Sotiris Filippidis
    0

    It's a set of extensions that are only in DLL format in the uMazel project, but here's the code to help you (metaSettings is obvious)

     public static string GetPageBrowserTitle(this IPublishedContent currPage, MetaSettings settings)
            {
                if (currPage == null) { return null; }
    
                IPublishedContent homePage = currPage.AncestorOrSelf(1);
                bool addSuffix = settings.AddSiteNameToBrowserTitle; 
                bool isHomePage = (homePage.Id == currPage.Id);
    
                string siteName = settings.SiteName;
                string pageTitle = string.Empty;
    
                if (currPage.HasValue(Constants.BrowserTitleOverridePropName))
                {
                    pageTitle = currPage.GetPropertyValue<string>(Constants.BrowserTitleOverridePropName);
                }
                else
                {
                    if (isHomePage)
                    {
                        pageTitle = (string.IsNullOrEmpty(siteName)) ? currPage.GetPageName() : siteName;
                    }
                    else
                    {
                        pageTitle = currPage.GetPageName();
                        pageTitle += (!string.IsNullOrEmpty(siteName) && addSuffix) ? string.Format(" - {0}", siteName) : "";
                    }
                }
    
                return (pageTitle);
            }
    
  • Rhett Lowson 2 posts 72 karma points
    Jun 21, 2017 @ 20:09
    Rhett Lowson
    0

    Thanks, I feel like I am just one step away from getting this working now. I was getting an error on the line that refers to Constants.BrowserTitleOverridePropName since this is not in the code snippet above, but I was able to work that one out. The solution is part working, but in some cases still getting the Vorto object error.

    There is still another level that is not exposed and that is where the error is actually being generated:

    pageTitle = DotSee.UmbracoExtensions.PageTitles.GetPageName(currPage);
    

    Am I right in guessing that the GetPageName method is part of the same DLL as the other snippet you listed?

  • Sotiris Filippidis 286 posts 1501 karma points
    Jun 21, 2017 @ 21:03
    Sotiris Filippidis
    0

    You're guessing correctly. I'm not giving the code for those DLLs for a couple of reasons, first because I'm using them in various projects and second because I change them all the time (and third, possibly, because I'm just ashamed of that code :) ). But if you really want to get it to work, you can either replace all those methods with your own - all they do is take the relevant field (node name, override title, breadcrumb/menu/inner title) and present it defaulting to other fields if it's not filled and eventually defaulting to the node name.

    If you really need to refer to the code, please let me know a way of sending it to you. I tried Twitter but you don't accept DMs

Please Sign in or register to post replies

Write your reply to:

Draft