+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Title for search engines - simple question

Title for search engines - simple question

6 posts, 1 answered
  1. Raul
    Raul avatar
    1 posts
    Registered:
    14 Oct 2011
    15 Dec 2011
    Link to this post
    Hi,

    I have a simple question.

    I would like to create a suffix for all of my pages. I intend to put this code in my master page. All I want to do is get the value of the "Title for search engines" from the code behind of the current page and append " - XYZ Company" to the title of every page, instead of manually doing it for every page.

    How do I get the property "Title for search engines" using the fluent API?

    Thanks
  2. Victor Velev
    Victor Velev avatar
    1345 posts
    Registered:
    06 Jul 2015
    15 Dec 2011
    Link to this post
    Hello Raul,

    You can access the field by getting Page.Htmltitle property. Please review the attached code which gets all pages with that particular title:

    App.WorkWith().Pages()
                   .Where(p => p.Page.HtmlTitle == "titleforsearchengines")
                   .Get();


    All the best,
    Victor Velev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Tim
    Tim avatar
    258 posts
    Registered:
    22 Jun 2011
    15 Dec 2011
    Link to this post
    Raul,

    This is a really simply way of doing it. You just need to put this in your master page:

    <title><%=Page.Title %> - XYZ Company</title>

    Answered
  4. Richard
    Richard avatar
    103 posts
    Registered:
    04 Apr 2013
    11 Sep 2014 in reply to Tim
    Link to this post

    Hey Tim,

     That gets the pages title, but the question was for the 'title for search engines'. I'm looking around for it now but if someone has that answer before I post it, would be appreciated. 

  5. Richard
    Richard avatar
    103 posts
    Registered:
    04 Apr 2013
    11 Sep 2014 in reply to Richard
    Link to this post

    Yup. Nice'en e.z. Just like SF. Could this be simplified or optimized?

                var currentPageNode = SiteMapBase.GetActualCurrentNode();

                IQueryable<PageNode> pageNodes = App.WorkWith().Pages()
                               .Where(p => p.Id == currentPageNode.Id)
                               .Get();
                foreach (var pageNode in pageNodes)
                {
                    var t = pageNode.Page.HtmlTitle;
                }


  6. Vassil Vassilev
     Vassil Vassilev avatar
    308 posts
    Registered:
    21 Jan 2015
    16 Sep 2014
    Link to this post
    Hello Richard,

    Here is a simpler way to get html title of the current page:
    var CurrentPageId = SiteMapBase.GetActualCurrentNode().Id;
    var HtmlTitle = PageManager.GetManager().GetPageNode(CurrentPageId).Page.HtmlTitle;

    Hope this helps.

    Regards,
    Vassil Vassilev
    Telerik
     
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
     
6 posts, 1 answered