Is it possible to get a reference to a Document node based on it's path ?
I have this scenario: I have created a mini-module and when I'm installing it on another umbraco solution, each node get different IDs and my code references some nodes based on their ID. So I'm trying to find a way to get a reference based on path nor the ID.
Referencing nodes based on their id is a real bad idea (and you've just found out why). I'd go with one of the following options:
- Change your code to accept node id's as parameter, so you don't have to rely on hard coded id's. I'm not sure whether that's applicable in your specific situation
- Create a package out of your local solution, include the nodes that you're referencing in your code and install package onto the other umbraco solution. (Be aware that it's still possible to have id clashes, so a check upfront in the db would'nt hurt)
Get Document by it's path
Hello,
Is it possible to get a reference to a Document node based on it's path ?
I have this scenario: I have created a mini-module and when I'm installing it on another umbraco solution, each node get different IDs and my code references some nodes based on their ID. So I'm trying to find a way to get a reference based on path nor the ID.
Thanks in advanced
Nicu
Hi Nicolae,
Referencing nodes based on their id is a real bad idea (and you've just found out why). I'd go with one of the following options:
- Change your code to accept node id's as parameter, so you don't have to rely on hard coded id's. I'm not sure whether that's applicable in your specific situation
- Create a package out of your local solution, include the nodes that you're referencing in your code and install package onto the other umbraco solution. (Be aware that it's still possible to have id clashes, so a check upfront in the db would'nt hurt)
Cheers,
/Dirk
Hi Dirk,
Thanks for quick reply;
I think using GUIDs instead of IDs to uniquelly identify "entities" in Umbraco will solve a lot af problems.
I will try you suggestion
Best
Nicu
is working on a reply...