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 @ 18:02
    Nicole Polet
    0

    I broke my umbraco forum thread !?

    I was having a very helpful conversation with Nicholas Westby when I posted some code and completely broke the thread...

    https://our.umbraco.org/forum/templates-partial-views-and-macros/77499-need-nodeids-to-be-the-same-on-both-dev-site-and-live-site

    I can no longer edit my comment or post a new comment, and I assume no one else can post comments there now either?

    Has this happened to anyone else?

    @Nicholas Westby- if you see this, can we continue the conversation here??

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    May 24, 2016 @ 18:26
    Nicholas Westby
    0

    Sure. Feel free to post your code again but use this button to format your code:

    // This is some example code.
    var sample = "code";
    

    Here's a screenshot that shows how to do it (sorry if the self-reference is confusing):

    Code

  • Nicole Polet 50 posts 202 karma points
    May 24, 2016 @ 18:37
    Nicole Polet
    0

    Thanks! I think that's what I did last time, it doesn't seem to like my code- keeps wanting to break out. I'll just put a screenshot of my code instead...

    enter image description here

    Hope you're able to open and read it...

  • Nicholas Westby 2054 posts 7104 karma points c-trib
    May 24, 2016 @ 19:06
    Nicholas Westby
    100

    You could do something like this (pay particular attention to the note about the code being slow because it will hit the database):

    // Replace this example GUID with a real one.
    var nodeGuid = new Guid("00000000-0000-0000-0000-000000000000");
    var service = ApplicationContext.Current.Services.ContentService;
    // This is slow because it hits the database.
    var dbContent = service.GetById(nodeGuid);
    var nodeId = dbContent.Id;
    var node = Umbraco.Content(nodeId);
    

    By the way, you can see the node GUID right under the node ID in the "Properties" tab:

    GUID

    I would recommend using content pickers or web.config settings to store the node ID's, but this should be an OK interim solution.

  • Nicole Polet 50 posts 202 karma points
    May 24, 2016 @ 19:27
    Nicole Polet
    0

    Yay, that worked! Thank you so much! Will this solution or changing web.config still work if we make this into a 1:1 multilingual site down the road?

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

    I would recommend replacing this approach first chance you get (hitting the database a bunch can be problematic for high load websites).

    However, I'm not sure what implications this has for multilingual websites.

  • Nicole Polet 50 posts 202 karma points
    May 24, 2016 @ 19:31
    Nicole Polet
    0

    OK, thanks again- I will make changing this a priority. Really appreciate your help :)

  • Kenneth Jakobsen 67 posts 203 karma points hq
    May 25, 2016 @ 10:39
    Kenneth Jakobsen
    0

    If you are going to be doing multilingual sites I would strongly recommend that you get rid of the "hard bindings to ids" as well, unless it is referring to a central repository

  • Nicole Polet 50 posts 202 karma points
    May 25, 2016 @ 16:29
    Nicole Polet
    0

    Thanks Kenneth, I'll definitely change this before we go multilingual with it.

  • 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