Copied to clipboard

Flag this post as spam?

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


  • Nicole Polet 50 posts 202 karma points
    May 24, 2016 @ 17:10
    Nicole Polet
    0

    Need NodeID's to be the same on both dev site and live site...

    Hello,

    I am in a giant time crunch to get a site up and running and I'm having a bit of a problem.

    I have a macro that finds a node by its ID and loops through its children. When I deployed the site to live I noticed that all my content node ID's are different on the live site, rendered my code useless.

    Obviously I'd like to find a better way to write this piece of code, but it's taking me too long to figure out and I really need a quick fix. Is there any way to ensure that the content node ID's on your live site match the ID's on your dev site?

    Thanks in advance!

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    May 24, 2016 @ 17:29
    Nicholas Westby
    0

    One way is to backup the entire database and overwrite the production database. Of course, that wipes out any data specific to your production environment.

    Alternatively, you can create a configuration file (or use app settings in your web.config) to store the node ID's. That way, each environment can use different node ID's.

    Another way would be to have a settings node (or nodes) in Umbraco that has content pickers that allow you to choose nodes by their ID's.

  • Nicholas Westby 2054 posts 7103 karma points c-trib
    May 24, 2016 @ 17:30
    Nicholas Westby
    0

    By the way, how did you deploy to your live site? If you used Courier, the node ID's would be different, but the node GUID's (aka, keys) would be identical. If you can use the GUID's rather than the integer ID's, that could be a workable solution.

  • Nicole Polet 50 posts 202 karma points
    May 24, 2016 @ 17:47
    Nicole Polet
    0

    Thanks your your replies Nicholas,

    I deployed the site via Courier. I actually have a separate problem where the other method of deployment (from the main umbraco page) didn't work for me. So I used Courier instead.

    I'm very new to Umbraco and Razor, so I'm not sure how I would go about using GUID's instead of node IDs. Here is my code... any help on this would be so much appreciated!

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
      @Traverse("1072")
      @Traverse("1087") @Traverse("1114")
      @Traverse("1131")
      @Traverse("1154")

    @helper Traverse(string nodeID) { var node = Umbraco.Content(nodeID);

  • @node.Name
  • foreach (var item in node.Children.Where("Visible").Where("hideFromFooter = false")) {
  • @if(item.HasValue("navLabel")) { @item.navLabel } else { @item.Name }
  • } }

Copy Link
Please Sign in or register to post replies

Write your reply to:

Draft