What's the best practice for creating a single page for dynamic content
I'll try and explain my situation to see if this makes sense. My site structure is like this:
Home
About
Contact
Properties
The Properties page is calling an external API to display a collection of real estate properties. The document type for Properties just has a couple basic properties, and my custom code does the rest.
What I'd like to do is have each of those properties link to a detail page, i.e. /properties/123. And then that detail page would check the id passed, and call the external API to get that data. So it'd be a single dynamic page, taking in an idea, that may or may not be managed in Umbraco.
My problem is that I don't know how to create that detail page. I thought about creating a Property Detail doc type and template, then creating a Detail page under Properties, and passing in the id through the query string. But that just seems...wrong. I don't like the idea of having a single page sitting in the tree structure.
I also was looking into route hijacking with a RenderMvcController, but it seems like that needs a Document Type and a page with that document type (unless I'm reading it incorrectly).
What would be the proper way to make this dynamic Properties Detail page?
Thanks Søren, but that doesn't seem very clear to me.
I'm not sure what the UmbracoVirtualNodeRouteHandler is supposed to do, and there's no example of an implementation on that page.
It says:
The instance of UmbracoVirtualNodeRouteHandler is responsible for
associating an IPublishedContent with this route.
Do I need a node created in the menu structure to use this? I'd rather not have a node sitting in the tree structure. If not, how does it render everything in the master template? Is having a doc type and template enough?
I feel like this would be a pretty common scenario, but seems like the least documented functionality. Is there a good example somewhere that you know of? I can't seem to find any.
If you’ve worked with MVC routes before this looks familiar but we do have one addition. We use the UmbracoVirtualNodeByIdRouteHandler to instantiate the root node of our site so that any products returned will be represented as children of the site root. That’s a very Umbraco approach, but enables us to use the existing Umbraco Views/Templates which may contain logic for working with IPublishedContent with our external data.
Try adding <h1>@Model.Content.Name</h1> to your details page, you
can see the Name of the underlying IPublishedContentfor this route -
eg. we are passing the details of the homepage.
What's the best practice for creating a single page for dynamic content
I'll try and explain my situation to see if this makes sense. My site structure is like this:
The Properties page is calling an external API to display a collection of real estate properties. The document type for Properties just has a couple basic properties, and my custom code does the rest.
What I'd like to do is have each of those properties link to a detail page, i.e. /properties/123. And then that detail page would check the id passed, and call the external API to get that data. So it'd be a single dynamic page, taking in an idea, that may or may not be managed in Umbraco.
My problem is that I don't know how to create that detail page. I thought about creating a Property Detail doc type and template, then creating a Detail page under Properties, and passing in the id through the query string. But that just seems...wrong. I don't like the idea of having a single page sitting in the tree structure.
I also was looking into route hijacking with a RenderMvcController, but it seems like that needs a Document Type and a page with that document type (unless I'm reading it incorrectly).
What would be the proper way to make this dynamic Properties Detail page?
Check out custom routes, that should help you :) https://our.umbraco.org/documentation/reference/routing/custom-routes
Although, you might need to have your url as /properties/property/123.
Thanks Søren, but that doesn't seem very clear to me.
I'm not sure what the UmbracoVirtualNodeRouteHandler is supposed to do, and there's no example of an implementation on that page.
It says:
Do I need a node created in the menu structure to use this? I'd rather not have a node sitting in the tree structure. If not, how does it render everything in the master template? Is having a doc type and template enough?
I feel like this would be a pretty common scenario, but seems like the least documented functionality. Is there a good example somewhere that you know of? I can't seem to find any.
Hi Steven
Here's an excerpt of the training docs
Hi Steven
I think I have some examples from some of my training docs. They are at work, so I will get back to you monday :)
is working on a reply...