Copied to clipboard

Flag this post as spam?

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


  • Frederik T 242 posts 373 karma points
    Apr 10, 2014 @ 17:46
    Frederik T
    0

    Show something at specific level

    I have something that should be simple but i cant crack the nut.

    I want something to be shown, when you are at a specific node level. And thats about it. But it always fails at that check, and i have no idea why.

    Also, some method of getting the previous pages url (so i dont have to use "onclick").

    @{
    var isMobileButton = Parameter.isMobilebutton;
    var startLevel = Parameter.startLevel;
    }

    @if (Model.AncestorOrSelf(startLevel))
    {
    if (!isMobileButton)
    {
    <div class="back-btn-medium">
    <a href="#" class="action icon-left-open" onClick=" history.back() "></a>
    </div>
    }
    else if (isMobileButton)
    {
    <div class="back-btn show-for-small-only">
    <a href="#" class="action action-high icon-left-open" onClick=" history.back() "></a>
    </div>
    }
    }
  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 10, 2014 @ 18:59
    Fuji Kusaka
    0

    Hi Frederik,

    So you basically want to display button on a specific level ? the button is always there ? 

  • Frederik T 242 posts 373 karma points
    Apr 10, 2014 @ 19:31
    Frederik T
    0

    Yeah. Its a back button, like a mobile app. From a specific level and downwards, it's always there.

  • Fuji Kusaka 2203 posts 4220 karma points
    Apr 10, 2014 @ 19:59
    Fuji Kusaka
    0

    So if you do something like this 

    var n =Model.AncestorOrSelf(1);
       
    foreach(var node in n.Descendants())
       
    {
           
    if(node.Level==2)
           
    {
    <div class="back-btn-medium">
                <a href="javascript:history.back()" class="action icon-left-open"></a>
            </div>
            }
            else {
                <div class="back-btn show-for-small-only">
                <a href="javascript:history.back()" class="action action-high icon-left-open"></a>
            </div>
            }
        }

     

  • Frederik T 242 posts 373 karma points
    Apr 10, 2014 @ 21:04
    Frederik T
    0

    Doesnt work, you cant do stuff like "node.Level == 2". I will try and fiddle some more with it. But i think you misunderstood what i meant, or maybe i dont understand your example.

  • Frederik T 242 posts 373 karma points
    Apr 24, 2014 @ 13:20
    Frederik T
    0

    Sorry to bump this, but i still havent figured this out...

  • Steve Morgan 1350 posts 4460 karma points c-trib
    Apr 29, 2014 @ 15:21
    Steve Morgan
    0

    Am I over simplifying what you're asking for but surely it's just something like this (replacing the @: outputs obviously with your button or nothing:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    
    
    @{
        var startLevel = 2;
    
        if(CurrentPage.Level > startLevel) {
            @:Button out here
        }
        else {
            @: No button
        }
    }
  • 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