Copied to clipboard

Flag this post as spam?

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


  • strawberrylatte 34 posts 103 karma points
    Mar 02, 2021 @ 05:29
    strawberrylatte
    0

    set link as static if doc type has no template

    I am very new to umbraco and I wanted to make the parent of my submenus to be static (#) if the doctype used has no template, so far these are what I have done.

                                        if (root != null)
                                        {
                                            foreach (var child in root.Children)
                                            {
                                                <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5818 @(Model.Url == child.Url ? "current-menu-item" : null)" style="display: flex; justify-content: space-between">
                                                    <a href="@child.Url">@child.Name</a>
                                                    @if (child.Children.Any() && !child.IsDocumentType("people"))
                                                    {
                                                        <button href="#" onclick="toggleChildMenu('child-@child.Id', this)" style="cursor: pointer; background: none; border: none; padding: 0 1rem; font-size: 1rem; color: rgb(140, 140, 140)">
                                                            <i class="fa fa-chevron-down" aria-hidden="true"></i>
                                                        </button>
                                                    }
                                                </li>
                                                if (child.Children.Any() && !child.IsDocumentType("people")) // don't show child nodes of people
                                                {
                                                    <li id="child-@child.Id" style="border: none; display: none;">
                                                        <ul style="margin-left: 1rem; margin-bottom: 0;" class="gdlr-core-custom-menu-widget gdlr-core-menu-style-list">
                                                            @foreach (var child2 in child.Children)
                                                            {
                                                                <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-5818 @(Model.Url == child2.Url ? "current-menu-item" : null)">
                                                                    <a href="@child2.Url">@child2.Name</a>
                                                                </li>
                                                            }
                                                        </ul>
                                                    </li>
                                                }
                                            }
                                        }
                                    }
    
  • Nevin George 12 posts 82 karma points
    Apr 20, 2021 @ 16:21
    Nevin George
    0

    Hi strawberrylatte,

    You can check whether a node is having template by using this code

    ​content.TemplateId.HasValue && content.TemplateId > 0

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies