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...
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:
I would recommend using content pickers or web.config settings to store the node ID's, but this should be an OK interim solution.
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
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??
Sure. Feel free to post your code again but use this button to format your code:
Here's a screenshot that shows how to do it (sorry if the self-reference is confusing):
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...
Hope you're able to open and read it...
You could do something like this (pay particular attention to the note about the code being slow because it will hit the database):
By the way, you can see the node GUID right under the node ID in the "Properties" tab:
I would recommend using content pickers or web.config settings to store the node ID's, but this should be an OK interim solution.
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?
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.
OK, thanks again- I will make changing this a priority. Really appreciate your help :)
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
Thanks Kenneth, I'll definitely change this before we go multilingual with it.
is working on a reply...