The sub content gets indexed but right now it will throw three "search results items" on my search page, one for each node. How would I combine these into the Main Content "search result item"?
You need to implement gathering node data event. In the event for the current page that is being indexed if it has template (you could use some other criteria eg if page that has these non template child pages is of type x then you could test for that).
If it does have template then get its child pages then get their content and put into new string the combined contents using stringbuilder then inject into the index for this page a new field. Call that field what ever you like then you can search on that field and you will get one result.
Thank you, I will look it up. A quick question regarding the class files, I'm kind of new to Umbraco and I'm not really a developer, more of a designer, so bare with me. Where in the solution would it be appropriate to place my class files? Can I make a new folder for this or should these be placed inside some specific folder?
Also, could you please post an example of what that code might look like?
Thank's for all the help. I've managed to combine the fields but I have a couple of questions regarding this.
In the combined field there is data like __Raw html data. Is it possible to exclude this, or any other from the combined field?
Also do I have to exclude the nodes (the children nodes with no templates) in the search result with razor code or am I doing something wrong in GatheringNodeData code if I have to do this?
Right now the parent of the children nodes with no templates will get the data from its children but I get the children as individual search results.
Combine examine search result
Greetings,
My content tree looks like this:
The sub content gets indexed but right now it will throw three "search results items" on my search page, one for each node. How would I combine these into the Main Content "search result item"?
Cheers!
David,
You need to implement gathering node data event. In the event for the current page that is being indexed if it has template (you could use some other criteria eg if page that has these non template child pages is of type x then you could test for that).
If it does have template then get its child pages then get their content and put into new string the combined contents using stringbuilder then inject into the index for this page a new field. Call that field what ever you like then you can search on that field and you will get one result.
Regards
Ismial
Hi Ismail,
Thank you, I will look it up. A quick question regarding the class files, I'm kind of new to Umbraco and I'm not really a developer, more of a designer, so bare with me. Where in the solution would it be appropriate to place my class files? Can I make a new folder for this or should these be placed inside some specific folder?
Also, could you please post an example of what that code might look like?
Best regards!
David
David,
Here is example of said class,
you need update the ExternalGatheringNodeData method and do your tests there then as I have done inject in a new field.
Are you working on a site built by someone else? Or did you create this site fresh? You will also need visual studio to add this code.
Regards
Ismail
Thanks Ismail,
I'm working on a inhouse project so I have access to everything and yes we are working with Visual Studio.
Cheers!
David
Hi Ismail,
Thank's for all the help. I've managed to combine the fields but I have a couple of questions regarding this.
In the combined field there is data like __Raw html data. Is it possible to exclude this, or any other from the combined field?
Also do I have to exclude the nodes (the children nodes with no templates) in the search result with razor code or am I doing something wrong in GatheringNodeData code if I have to do this?
Right now the parent of the children nodes with no templates will get the data from its children but I get the children as individual search results.
Best regards
David,
You will need to exclude them in the search. Not sure what you mean by __Raw fields are in combined field?
Regards
Ismail
David,
What is the project structure in visual studio? Do you have web project and other projects for the other layers?
Regards
Ismail
It is a single web application project, no other projects share any data or files. The file structure looks like this:
Best regards
You can then create class file and put it in app_code folder which you do not have but you can add it. When site loads it will run that class file
Love you avatar btw big fan of street fighter prefer fighting with guile myself
Awsome, thanks Ismail!
Yeah, nothing beats a good street fight! :D
I get a compilation error. looks like "Helpers" does not exists in namespace "UmbracoSiteExtensions"?
I've read that this is a custom addition namespace and this should work with v7.
Best regards
David
is working on a reply...