umco / umbraco-ezsearch

A simple search package for Umbraco
https://our.umbraco.org/projects/website-utilities/ezsearch
MIT License
6 stars 10 forks source link

Get corrected URL in search results #9

Open Tessachu opened 9 years ago

Tessachu commented 9 years ago

It's not necessarily an issue, but a feature request. I'll use my example to explain what I'm asking for.

I created a dynamic FAQ page, so that the parent node has a template that loops through and displays all of the children nodes (which holds a single question and answer per child) on the parent's URL, /faq. None of the children nodes use a template because I don't anticipate using those URLs that get generated.

I want the FAQ page to be searchable, but as it works right now, the results that get pulled from searching through the FAQ's questions and answers links to the default URLs of those children, which results in 404 pages when clicked because they simply don't have templates. My goal is for those links to be redirected to a specified URL.

Now these children nodes have the special "umbracoURLAlias" and "umbracoUrlName" properties. The latter which changes the URL relative to its parent, so it's not really any help redirecting to its parent, and it would still result in a 404 because again, this node doesn't have a template. The former only works when the value in the property has been typed into the browser, so it doesn't necessarily apply in this situation, because the /faq URL already exists, it just renders that page instead of the children pages using it as an alias. Essentially, it does nothing for this particular case.

So I was wondering if you could set it up, or if you could teach me how to set it up because I'm not quite that adept at MVC or C# yet, so that when it renders the link for the URL, if it could first check for the "umbracoURLAlias" or other specified property name, and if that's left blank, then use the default URL as usual.

Please and thanks!

harvzor commented 8 years ago

TL;DR:

If a node has a rewritten path (using umbracoUrlAlias or umbracoUrlName) then check to see if that path 404s, if it doesn't, display the result.

If a node does not have a rewritten path, then check if it has a template, if it doesn't, display the result.

If the node does not have a rewritten path, does have a template, display the result as normal.