Copied to clipboard

Flag this post as spam?

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


  • Sam 63 posts 126 karma points
    Jul 11, 2015 @ 17:50
    Sam
    0

    Target a certain nodeid with inline script in umbraco template

    Hi all, ok am going for the long explanation here..sorry 'bout that.

    I have a template which i used to create various inner pages. But now I have to insert a div in only one of the inner page.

    So i will insert the html code in the template but i want to wrap it in a condition to check when the current page has nodeID i want it to render in.

    Is this clear enough and how do i do that.

    Thks for your precious help.

    Am using Umbraco 7

  • Proxicode 119 posts 305 karma points
    Jul 11, 2015 @ 18:53
    Proxicode
    0

    Hi Sam,

    If I am understanding you correctly something like below should work fine. It's untested, but hopefully it will be enough to get you on your way.

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
    Layout = "Master.cshtml";
    }
    <!-- MAIN CONTENT -->
    <div id="main">
            // stuff for all pages
            // stuff for all pages
            // stuff for all pages
            @if(CurrentPage.Id == 1200)
            {
                 <div id="special">
                      // this stuff is just for this one page
                 </div>
            }
    </div>
    
  • Sam 63 posts 126 karma points
    Jul 12, 2015 @ 14:29
    Sam
    0

    Hi thanks will try that..

    //Sam

  • Sam 63 posts 126 karma points
    Jul 12, 2015 @ 15:34
    Sam
    101

    ok get it to work with that:

                          @if(Model.Id == 1000)
                            {
                                   @:<div class="mydiv"></div>
                            }                       
                        </umbraco:Macro>    
    
  • Proxicode 119 posts 305 karma points
    Jul 13, 2015 @ 16:55
    Proxicode
    0

    Good to hear Sam! Would you mind marking my answer as the solution? Thanks - and glad you got it working. -Roger

  • 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