Copied to clipboard

Flag this post as spam?

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


  • Tanuwijaya 7 posts 64 karma points
    Sep 14, 2014 @ 09:11
    Tanuwijaya
    0

    How to display the page title?

    Hello,

    I follow this link: http://our.umbraco.org/documentation/Using-Umbraco/Creating-Basic-Site/

    But I something bother me, there're pages that show the page title (like Contact Us), but there're also pages that don't show the page title (like the article main and its detail).

    What should I put on the template(?) that can show that page title?

    Thank you in advance for the help.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Sep 14, 2014 @ 11:04
    Dennis Aaen
    100

    Hi Tanuwijaya,

    If you have a master layout where you put our basic markup for header body and footer you should place the title tag in the head.

    And you could do something like this. In the case it first, see if there are some content in the field called title on  the page that you are viewing in the browser, if it´s empty then it takes the page of the page,

    @Umbraco.Field("title", altFieldAlias: "pageName")

    http://our.umbraco.org/documentation/Reference/Mvc/views#RenderingafieldwithUmbracoHelper

    Or you could just do this if you don´t need a fallback field

    @Umbraco.Field("pageName")

    Your markup would look something like this:

    <!DOCTYPE html>
    <head>
        <title>@Umbraco.Field("title", altFieldAlias: "pageName")</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
        <link href="http://fonts.googleapis.com/css?family=Open+Sans:400,700|Open+Sans+Condensed:700" rel="stylesheet" />
        <script src="/js/jquery.min.js"></script>
        <script src="/js/config.js"></script>
        <script src="/js/skel.min.js"></script>
        <script src="/js/skel-panels.min.js"></script>
        <noscript>
            <link rel="stylesheet" href="/css/skel-noscript.css" />
            <link rel="stylesheet" href="/css/style.css" />
            <link rel="stylesheet" href="/css/style-desktop.css" />
        </noscript>
        <!--[if lte IE 9]><link rel="stylesheet" href="/css/ie9.css" /><![endif]-->
        <!--[if lte IE 8]><script src="/js/html5shiv.js"></script><link rel="stylesheet" href="/css/ie8.css" /><![endif]-->
        <!--[if lte IE 7]><link rel="stylesheet" href="/css/ie7.css" /><![endif]-->
    </head>
    <body>
        ....
    </body>
    </html>

    This example is from the TXT starter kit.

    Hope this helps, if you have any other questions don't hesitate to ask again.

    /Dennis

  • Tanuwijaya 7 posts 64 karma points
    Sep 15, 2014 @ 00:52
    Tanuwijaya
    0

    Hi Dennis,

    Thank you very much for your reply. It seems that on the pages I mention before I don't have any pageTitle properties (field?) around. After I add it. Then there is page title on all the pages.

    Once again thank you for the help and detail explanation.

Please Sign in or register to post replies

Write your reply to:

Draft