ezSearch add more details into the results container
Hi,
I am using the ezSearch package in my latest project. Everything is working fine but I want to add more details in the result.
I have edit the ezSearch template manually because some required fields are standard umbraco property fields. And using the previewFields you can't access them ( like for example displaying the url ).
But what I would like to add is something like Google. A breadcrumb list to the result page with links to all the parents.
How can I do this?
Do I need to create a new macro and call this in the ezSearch macro in some sort of way or...
Well, I don't know if this will work out of the box, and it will probably need some tweaking, but the general idea is as follows:
The RenderContentResult helper (ezSearch.cshtml, line 250 currently on GitHub) knows the IPublishedContent that you are displaying at that time.
What you could probably do is create a partial view (under /Views/Partials, let's call it PageBreadcrumb.cshtml) which will render a breadcrumb and call it from there. Here's a simple partial view for that:
@inherits Umbraco.Web.Mvc.UmbracoViewPage
@{
IPublishedContent currPage = Model;
string[] breadcrumbIds = currPage.Path.Split(',');
foreach (string breadcrumbId in breadcrumbIds)
{
int id = int.Parse(breadcrumbId);
if (id > 0)
{
IPublishedContent item = Umbraco.TypedContent(id);
if (item.IsVisible() && !breadcrumbId.Equals(breadcrumbIds.Last()))
{
<a href="@Umbraco.NiceUrl(id)">@item.Name</a> @Html.Raw("/ ");
}
if (breadcrumbId.Equals(breadcrumbIds.Last()))
{
<span>@item.Name</span>
}
}
}
}
Where "result" is the IPublishedContent passed as parameter to the helper function.
This could also be a macro, not a partial view, but it was easier to show you with a partial view since I already had the code handy. Please give it a try and let me know if you managed it or got stuck somewhere.
ezSearch add more details into the results container
Hi,
I am using the ezSearch package in my latest project. Everything is working fine but I want to add more details in the result.
I have edit the ezSearch template manually because some required fields are standard umbraco property fields. And using the previewFields you can't access them ( like for example displaying the url ).
But what I would like to add is something like Google. A breadcrumb list to the result page with links to all the parents.
How can I do this?
Do I need to create a new macro and call this in the ezSearch macro in some sort of way or...
Can anyone guide me in this?
/Michael
Well, I don't know if this will work out of the box, and it will probably need some tweaking, but the general idea is as follows:
The RenderContentResult helper (ezSearch.cshtml, line 250 currently on GitHub) knows the IPublishedContent that you are displaying at that time.
What you could probably do is create a partial view (under /Views/Partials, let's call it PageBreadcrumb.cshtml) which will render a breadcrumb and call it from there. Here's a simple partial view for that:
And call it like this:
Where "result" is the IPublishedContent passed as parameter to the helper function.
This could also be a macro, not a partial view, but it was easier to show you with a partial view since I already had the code handy. Please give it a try and let me know if you managed it or got stuck somewhere.
Ok got it working using the suggesting of creating a new macro and call this in the ezSearch macro.
1) Created a new Macro with one param Content Picker which contains the id of the current node
2) Called the macro from ezSearch and give the result id as param to the macro
/Michael
That's great. Essentially it's the same thing, happy to know it worked for you!
is working on a reply...