Try our conversational search powered by Generative AI!

Page full path

Vote:
 

I am creating a job in CMS 11 and I need to get the full path of the page for my report that I am creating.  Here is what I have and I know I can run SQL to get it but trying to avoid that if possible.  What I would like it to return is something like this "Root/AS/Franchises/Shared/Franchise Defaults/Fallback Site/Home/Underwriting/Products/Life/News and  Events/".  I can get that by running my SQL and passing the page.ContentLink.ID but I want to learn the C# way of doing it.  Thanks for the help.  

var _loader = ServiceLocator.Current.GetInstance<IContentLoader>();
// Get all descendants of the Shared site
var pages = _loader.GetDescendents(SharedSite).Select(c => _loader.Get<IContent>(c)).ToList();

// Iterate them...
            foreach (var page in pages)
            {
                Log($"Start: \"{page.Name}\" (ID: {page.ContentLink.ID})");

#304240
Jun 28, 2023 14:06
Vote:
 

Hi Scott,

Take a look at this blog post should have everthing you need: https://world.optimizely.com/blogs/ravindra-s--rathore/dates/2019/8/retrieve-relative-url-of-a-page-on-page-or-block/

Just be aware scheduled jobs are run it a different context or without context you can read more about how they work here: https://blog.tech-fellow.net/2020/12/07/episerver-scheduled-jobs-under-the-hood/

Paul

#304249
Jun 28, 2023 15:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.