Copied to clipboard

Flag this post as spam?

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


  • Abdul Raheem 17 posts 61 karma points
    Oct 27, 2014 @ 10:11
    Abdul Raheem
    0

    How to create dynamic footer link using related links document type in Umbraco 7

    Hi, I am noobie.

    I am trying to crate dynamic footer links for my website using related link document type. I created a footer partail view and call the realted link document type in the partial view and on masterlayout i have called the partial view but this documetn type is only displayed on the home page, I want these links to appear on all the pages of my website.

    here is my partail view code.

    @inherits UmbracoTemplatePage
    @using Newtonsoft.Json.Linq
    @{
        if (Model.Content.HasValue("whoWeDoItFor"))
        {
    
                <ul >
                    @{
            var dynamicLinks = Model.Content.AncestorOrSelf("whoWeDoItFor");
                        //var x = Model.Content.GetPropertyValue<string>("whoWeDoItFor");
    
                        var Links = Model.Content.GetPropertyValue<JArray>("whoWeDoItFor");
                            <li>
    
                                    <div>
                                        @if (Links.Any())
                                        {
                                            <ul>
                                                @foreach (var linkItem in Links)
                                                {
                                                    var linkUrl = (linkItem.Value<bool>("isInternal")) ? Umbraco.NiceUrl(linkItem.Value<int>("internal")) : linkItem.Value<string>("link");
                                                    var linkTarget = linkItem.Value<bool>("newWindow") ? "_blank" : null;
                                                    <li><a href="@linkUrl" target="@linkTarget">@(linkItem.Value<string>("caption"))</a></li>
                                                }
                                            </ul>
                                        }
                                    </div>
    
                            </li>
                        }
    
                </ul>
    
        }
    }

    Please help me, how I can make these links to appear on all the web pages

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 27, 2014 @ 12:58
    Dennis Aaen
    1

    Hi Abdul,

    Try this code instead:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @using Newtonsoft.Json.Linq
    @{     
        if (Model.Content.HasValue("whoWeDoItFor", true) && Model.Content.GetPropertyValue<string>("whoWeDoItFor", true).Length > 2)
        {
            <ul>
                @foreach (var item in Model.Content.GetPropertyValue<JArray>("whoWeDoItFor", true))
                {
                    var linkUrl = (item.Value<bool>("isInternal")) ? Umbraco.NiceUrl(item.Value<int>("internal")) : item.Value<string>("link");
                    var linkTarget = item.Value<bool>("newWindow") ? "_blank" : null;
                    <li><a href="@linkUrl" target="@linkTarget">@(item.Value<string>("caption"))</a></li>
                }
            </ul>
        }

    You can find the documentation for the related links property editor here: http://our.umbraco.org/documentation/Using-Umbraco/Backoffice-Overview/Property-Editors/Built-in-Property-Editors-v7/Related-Links In my example I assume that your alias of the property is: whoWeDoItFor. And I have added the property on my home document type.

    Hope this helps,

    /Dennis

  • Abdul Raheem 17 posts 61 karma points
    Oct 27, 2014 @ 13:41
    Abdul Raheem
    0

    Hi Denis,

    Thanks alot, It worked!! :)

    Cheers 

Please Sign in or register to post replies

Write your reply to:

Draft