Copied to clipboard

Flag this post as spam?

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


  • Hubert Thalmann 57 posts 263 karma points
    Sep 15, 2016 @ 07:36
    Hubert Thalmann
    0

    Hello our.umbraco

    I created a new Documenttype called "Master" and tried to get the "Umbraco.Fields" at my Master Template but it didn't work.

    (for example Navigation Points)

    How can i link my Master Documenttype to my Master Template that i can use Umbraco.Field("test") at my Master Template?

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 15, 2016 @ 10:03
    Alex Skrypnyk
    0

    Hi Hubert,

    Did you select "Master Template" as template of Master page?

    How did you try to get "Umbraco.Fields" ? Can you share the code?

    Thanks,

    Alex

  • Hubert Thalmann 57 posts 263 karma points
    Sep 15, 2016 @ 11:49
    Hubert Thalmann
    0

    enter image description hereenter image description here

    enter image description hereenter image description here

    <li id="navHome" class="rightmenu"><a class="menu" href="~/Home" id="klickbar">@Umbraco.Field("text")</a></li>
    

    am i doing something wrong?

    ty

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 15, 2016 @ 12:40
    Alex Skrypnyk
    0

    And how did you try to render the page ? your code please?

  • Hubert Thalmann 57 posts 263 karma points
    Sep 15, 2016 @ 12:45
    Hubert Thalmann
    0
    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = null;
        var home = @CurrentPage.Site();
    }
    
    <!DOCTYPE html>
    <html lang="de">
    <head>
        <title>@(ViewBag.Title) - JK Flühli</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!--<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">-->
        <link href="~/css/bootstrap.css" rel="stylesheet" />
        <script type='text/javascript' src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
        <script type='text/javascript' src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        <script type='text/javascript' src='http://www.1atools.eu/services/guestbook/js/jquery.validate.js'></script>
        <script type='text/javascript' src="~/js/main.js"></script>
        <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet" type="text/css" /> 
        <link href='https://fonts.googleapis.com/css?family=Candal' rel='stylesheet' type='text/css'>
        <link rel='shortcut icon' type='image/x-icon' href='~/images/favicon.ico'/>
        <link href="~/css/lightbox.css" rel="stylesheet">
    
    
        <link rel="stylesheet" href="~/css/style.css">
    
    
     @{ 
               if (CurrentPage.HasValue("logomobile")){ 
                  var dynamicMediaItem = Umbraco.Media(CurrentPage.logomobile); 
                <style>
                        .logo{
                             background-color: red;
                        }
                </style>
             } 
    }
    
    
        <script type="text/javascript">
    
            function show(id) {
                if (document.getElementById) {
                    var mydiv = document.getElementById(id);
                    mydiv.style.display = (mydiv.style.display == 'block' ? 'none' : 'block');
                }
            }
        </script>
    
    
    
        <script type="text/javascript">
            $(document).ready(function () {         
                /* Hier der jQuery-Code */
                $('#sobo-einausblenden1').click(function () {
                    $('#subnav4').hide();
                    $('#subnav2').hide();
                    $('#subnav3').hide();
                    $('#subnav1').toggle(500);
                    setTimeout(function(){ 
                    if($('#subnav1').css('display') == 'block'){
                        $("#custom-nav").removeClass("shadow");
                    }else{
                        $("#custom-nav").addClass("shadow");
                    }
                    }, 510);        
                })
            });     
        </script>
        <script type="text/javascript">
            $(document).ready(function () {
                /* Hier der jQuery-Code */
                $('#sobo-einausblenden2').click(function () {
                    $('#subnav1').hide();
                    $('#subnav4').hide();
                    $('#subnav3').hide();
                    $('#subnav2').toggle(500);
                    setTimeout(function(){ 
                    if($('#subnav2').css('display') == 'block'){
                        $("#custom-nav").removeClass("shadow");
                    }else{
                        $("#custom-nav").addClass("shadow");
                    }
                    }, 510);                
                })
            });
        </script>
        <script type="text/javascript">
            $(document).ready(function () {
                /* Hier der jQuery-Code */
                $('#sobo-einausblenden3').click(function () {
                    $('#subnav1').hide();
                    $('#subnav2').hide();
                    $('#subnav4').hide();
                    $('#subnav3').toggle(500);
                    setTimeout(function(){ 
                    if($('#subnav3').css('display') == 'block'){
                        $("#custom-nav").removeClass("shadow");
                    }else{
                        $("#custom-nav").addClass("shadow");
                    }
                    }, 510);        
                })
            });
        </script>
        <script type="text/javascript">
            $(document).ready(function () {
                /* Hier der jQuery-Code */
                $('#sobo-einausblenden4').click(function () {
                    $('#subnav1').hide();
                    $('#subnav2').hide();
                    $('#subnav3').hide();
                    $('#subnav4').toggle(500);
                    setTimeout(function(){ 
                    if($('#subnav4').css('display') == 'block'){
                        $("#custom-nav").removeClass("shadow");
                    }else{
                        $("#custom-nav").addClass("shadow");
                    }
                    }, 510);        
                })
            });
    
    
            $(document).ready(function () {
                /* Hier der jQuery-Code */
                $('#alleweg').click(function () {
                    $('#subnav1').hide();
                    $('#subnav2').hide();
                    $('#subnav3').hide();
                    $('#subnav4').hide();
                })
            });
        </script>
    </head>
    
    
    
    
    <body id="@(ViewBag.Id)">
            <div class="backgroundDiv">
                            </div>
        <nav class="navbar navbar-default navbar-center navbar-fixed-top" id="custom-nav">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                        <img src="~/images/icon_menu_mobile.png" alt="menuicon"/>
                    </button>
                </div>
                <div class="collapse navbar-collapse" id="myNavbar">
                    <ul class="nav navbar-nav">
                        <li id="navHome" class="rightmenu"><a class="menu" href="~/Home" id="klickbar">@Umbraco.Field("text")</a></li>
                        <li id="navAktuell" class="rightmenu menupoint"><a class="menu" style="cursor:pointer;" id="sobo-einausblenden1">Aktuell</a></li>
                        <li id="navGV" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Aktuelles">GV-Bericht</a></li>
                        <li id="navAnlaesse" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Anlaesse">Anlässe</a></li>
                        <li id="navGalerie" class="rightmenu menupoint"><a class="menu" style="cursor:pointer;" id="sobo-einausblenden2">Galerie</a></li>
                        <li id="navBilder" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Bilder">Bilder</a></li>
                        <li id="navHoerprobe" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Hoerprobe">Hörprobe</a></li>
                        <li id="navUeberuns" class="rightmenu menupoint"><a class="menu" style="cursor:pointer;" id="sobo-einausblenden3">Über uns</a></li>
                        <li id="navMitglieder" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Mitglieder">Mitglieder</a></li>
                        <li id="navAktive" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Aktive">Aktive</a></li>
                        <li id="navPassive" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Passive">Passive</a></li>
                        <li id="navGaestebuch" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Gaestebuch">Gästebuch</a></li>
                        <li id="navArchiv" class="rightmenu menupoint"><a class="menu" style="cursor:pointer;" id="sobo-einausblenden4">Archiv</a></li>
                        <li id="navArchivU" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Archivvorstand">Vorstand</a></li>
                        <li id="navSpezAnlaesse" class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Spezanlaesse">Spezielle Anlässe</a></li>
                        <li class="desktopausblenden lastpoint"><a class="menu" id="unterpunkt" href="~/Links">Links</a></li>
                        <li class="desktopausblenden"><a class="menu" id="unterpunkt" href="~/Impressum">Impressum</a></li>
                        <li class="desktopausblenden"><a class="menu" id="unterpunkt" href="mailto:[email protected]?Subject=Kontakt" target="_top">Kontakt</a></li>
                        <li class="desktopausblenden"><a class="menu" id="unterpunkt" href="http://www.facebook.com"><img class="desktopausblenden" src="~/images/icon_facebook_mobile.png" alt="Facebook"/></a></li>
                        <li class="desktopausblenden lastpoint"><a class="menu" id="unterpunkt" href="http://www.youtube.com"><img class="desktopausblenden" src="~/images/icon_youtube_mobile.png" alt="Facebook" /></a></li>
                    </ul>
                </div>
            </div>
        </nav>
        <div>
            <div class="navbar navbar-collapse subnavItem" id="subnav1">
                <ul class="nav navbar-nav">
                    <li id="navAktuelles" class="rightmenu"><a class="submenu" href="~/Aktuelles">GV-Bericht</a></li>
                    <li id="navAnlaesse" class="rightmenu"><a class="submenu" href="~/Anlaesse">Anlässe</a></li>
                </ul>
            </div>
    
            <div class="navbar navbar-collapse subnavItem" id="subnav2">
                <ul class="nav navbar-nav">
                    <li id="navBilder" class="rightmenu"><a class="submenu" href="~/Bilder">Bilder</a></li>
                    <li id="navHoerprobe" class="rightmenu"><a class="submenu" href="~/Hoerprobe">Hörprobe</a></li>
                </ul>
            </div>
    
            <div class="navbar navbar-collapse subnavItem" id="subnav3">
                <ul class="nav navbar-nav">
                    <li id="navMitglieder" class="rightmenu"><a class="submenu" href="~/Mitglieder">Mitglieder</a></li>
                    <li id="navAktive" class="rightmenu"><a class="submenu" href="~/Aktive">Aktive</a></li>
                    <li id="navPassive" class="rightmenu"><a class="submenu" href="~/Passive">Passive</a></li>
                    <li id="navGaestebuch" class="rightmenu"><a class="submenu" href="~/Gaestebuch">Gästebuch</a></li>
                </ul>
            </div>
    
            <div class="navbar navbar-collapse subnavItem" id="subnav4">
                <ul class="nav navbar-nav">
                    <li id="navArchivu" class="rightmenu"><a class="submenu" href="~/Archivvorstand">Vorstand</a></li>
                    <li id="navSpezAnlaesse" class="rightmenu"><a class="submenu" href="~/SpezAnlaesse">Spezielle Anlässe</a></li>
                    <li id="navLinks" class="rightmenu"><a class="submenu" href="~/Links">Links</a></li>
                </ul>
            </div>
        </div>
        <div style="cursor:pointer;"  onclick="window.open('https://www.facebook.com/jkfluehli', '_blank')" class="facebook"></div>
        <div style="cursor:pointer;"  onclick="window.open('https://www.youtube.com/channel/UCB2VzQ-AYst6hoZfRORQ-aw', '_blank')" class="youtube"></div>
        <div style="cursor:pointer;"  onclick="location.href = 'Home';" class="logo"></div>
    
    
    
        <div class="container withpadding">
            <div class="titleimagemobile"></div>
        </div>
        <div class="container withpadding bg2 margin" id="contentcontainer">
    
    
    
        @RenderBody()
    
                </div>
        <div class="footer">
            <div class="container">
                <div class="row ">
                    <div id="footer1" class="footercontent">
                        © by us
                    </div>
                    <div id="footer2" class="footercontent footerlinks">
                        <a class="footerlinks" href="~/Impressum">Impressum</a>
                    </div>
                    <div id="footer3" class="footercontent">
                        <a class="footerlinks" href="mailto:asgfag?Subject=Kontakt" target="_top">Kontakt</a>
                    </div>
                </div>
            </div>
        </div>
        <script src="~/js/lightbox.js"></script>
    
    </body>
    </html>
    
  • Hubert Thalmann 57 posts 263 karma points
    Sep 15, 2016 @ 14:35
    Hubert Thalmann
    0

    is renders but i doesnt render the:

    <li id="navHome" class="rightmenu"><a class="menu" href="~/Home" id="klickbar">@Umbraco.Field("text")</a></li>
    

    its empty...

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Sep 15, 2016 @ 17:17
    Alex Skrypnyk
    0

    Only this field?

    Try this line of code -

    @Html.Raw(Umbraco.Field("text"))
    
  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 07:22
    Hubert Thalmann
    0

    doesn't work.

    Its confusing. When i make the Template under an other Master Template the Umbraco.Field works. But when i make the Template to a Master Template i don't have access to the Documenttype anymore.

    Please help.

  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 07:38
    Hubert Thalmann
    0

    no not only this field. It doens't render all fields.

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 19, 2016 @ 08:28
    Steve Morgan
    1

    Hi Hubert,

    Are you trying to use your master "template" to hold content that you want to reuse on multiple pages across your site?

    If so I think you've misunderstood what a master template does. What you're looking for can be done easily however. I'll explain how if you can confirm I've understood you correctly?

    Steve

  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 09:03
    Hubert Thalmann
    0

    yes, thats what i use my mastertemplate for. In Master Template i have my Navigation and Footer.. and at "RenderBody" i Render my Content, that is different on every page.

    Am i doing it wrong?

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 19, 2016 @ 09:38
    Steve Morgan
    100

    OK - I can see where you're confused... Basically you can use master templates / doc types to do what you're doing for the common content but you also need to access data from a different content node to the one that's being requested to get the header and footer content.

    Here's a quick overview of the terminology so there's no confusion!

    Master template - a template that other templates use that contains common header / footer / html skeleton / Umbraco field requests.

    Master Doc type - a doc type that all doc types below it will inherit the doc type fields (data / content "fields"). This paradigm has recently (mostly) been replaced with Doc Type compositions where you build up a doctype from other ones rather than inherit.

    Content - content nodes in the tree - from a template (either within the template itself or a master) you can "traverse" up the tree to get content either from the content node requested or one of it's parents... e.g.

    Home
    - News
     - - August 2016
     - - - some Article 
    

    If page "Some Article" was requested Umbraco will use the doc type and template for this content node but you might also use content from the news home or August 2016 or even the home node if the same value is not set on "Some Article" .. to do this you'd request the property value recursively (so it traverses up the tree).

     // get the value from the current content node or travel up it's parents
        @Umbraco.Field("text", true)
    

    Using the above method you could therefore put your header and footer information in the Home node and always request it recursively. I don't like doing this - I think what you're trying to do (which is how I build sites) is to have a common container of this content outside of the content tree - I tend to call this "Site Settings" rather than Master to avoid confusion with the doc type / template stuff.

    You basically do what you've done, create a doc type called Site settings and create the content fields for your header / footer content (no need for master doc types!). Then within your page templates (e.g. for the news article, homepage and news container in the example above) you just need to "Get" a reference to the site settings node as Umbraco will only contain the content from the current node (or allow you to recursively work up the parents as above).

    To do this at the top of your template you need something like:

    int siteSettingsNodeId = 1234; // check the properties tab of your site settings node get this - it will be different for your site!
    var siteSettingsNode = Umbraco.TypedContent(siteSettingsNodeId);
    

    Now you can use the siteSettingsNode where need common content as well as content from the CurrentPage - as this is strongly typed node you access the fields like this:

    @(siteSettingsNode.GetPropertyValue<string>("Text")) 
    

    or for rich text:

    @(siteSettingsNode.GetPropertyValue<HtmlString>("Text")) 
    

    Hopefully this will put you on the right path.

    Steve

  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 09:51
    Hubert Thalmann
    0

    Oh god now i get it... Thank you so much!

  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 09:54
    Hubert Thalmann
    0

    Textboxes are

    what are images? mediapaths?

    can u help me? ;)

    if have for example an media picker and i want the path of the image who is selected?

  • Steve Morgan 1346 posts 4453 karma points c-trib
    Sep 19, 2016 @ 10:01
    Steve Morgan
    1

    Now you have the above the documentation should make more sense... so where you see Model.Content. replace with siteSettingsNode

    How to use a Media Picker

    (note I suggest you follow the Typed examples). Remember how we used Umbraco.TypedContent - well notice how these are TypedMedia.. hopefully the mist will begin to clear!

    Steve

  • Michaël Vanbrabandt 863 posts 3348 karma points c-trib
    Sep 19, 2016 @ 10:01
    Michaël Vanbrabandt
    1

    Hubert,

    if you want to display the image from your media picker then you could do something like:

    if(siteSettingsNode.HasValue("propertyAliasofYourMediaPicker"))
    {
        var _image = Umbraco.Media(siteSettingsNode.GetPropertyValue("propertyAliasofYourMediaPicker"));
    
        <img src="_image.GetPropertyValue("umbracoFile")" />
    }
    

    /Michaël

  • Hubert Thalmann 57 posts 263 karma points
    Sep 19, 2016 @ 11:27
    Hubert Thalmann
    1

    thank you both! :) its now clear to me. cu

Please Sign in or register to post replies

Write your reply to:

Draft