getgrav / grav-plugin-simplesearch

Grav SimpleSearch Plugin
https://getgrav.org
MIT License
44 stars 55 forks source link

how to search in custom fields? #135

Open manuel-84 opened 6 years ago

manuel-84 commented 6 years ago

I have defined a custom blueprint with my fields for some pages and the texts are displayed with a twig template. How to add text fields in search?

ThosG commented 6 years ago

This is a need for me too. @manuel-84 , did you find a way?

manuel-84 commented 6 years ago

@ThosG No, sorry, I haven't had time to work on this

ThosG commented 6 years ago

I have hacked the code to make Simplesearch look at fields and it seems to work. Can anyone tell me how I go about making this a public contribution? I've never done any open source work.

rhukster commented 6 years ago

You need to create a pull request: https://help.github.com/articles/creating-a-pull-request/

ThosG commented 6 years ago

I see. OK, will do tomorrow. Thanks

Thomas

On 8 Jan 2018, at 21:30, Andy Miller notifications@github.com wrote:

You need to create a pull request: https://help.github.com/articles/creating-a-pull-request/ https://help.github.com/articles/creating-a-pull-request/ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getgrav/grav-plugin-simplesearch/issues/135#issuecomment-356102640, or mute the thread https://github.com/notifications/unsubscribe-auth/AKfmR1TQG4UmllFjJGj7jMpu9pKiPBi5ks5tIoj6gaJpZM4QbeTH.

ThosG commented 6 years ago

I’m sorry Andy, but I really don’t understand enough of this! It keeps saying I need to compare things, and I don’t know what it means.

What I’ve done is quite simple, I’ve added a few lines of code so that SimpleSearch searches fields as well as titles, taxonomy, and contents. So I have the hacked file. Can you point me to something designed for total newbies to github, something that holds me by the hand? I’m not a developer, and I don’t aspire to become one, so I don’t want or need to learn github: I just want to pass this simple addition on for anyone else who needs it.

Sorry to be so ignorant.

Thomas Green

On 8 Jan 2018, at 21:30, Andy Miller notifications@github.com wrote:

You need to create a pull request: https://help.github.com/articles/creating-a-pull-request/ https://help.github.com/articles/creating-a-pull-request/ — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/getgrav/grav-plugin-simplesearch/issues/135#issuecomment-356102640, or mute the thread https://github.com/notifications/unsubscribe-auth/AKfmR1TQG4UmllFjJGj7jMpu9pKiPBi5ks5tIoj6gaJpZM4QbeTH.

manuel-84 commented 6 years ago

@ThosG can you explain here the edits you've done? thank you!

ThosG commented 6 years ago

@manuel-84 Hi, thanks for being interested. I know that what I ought t do is to do a pull request, but I don't understand the procedure, and I'm reluctant to invest the time required to find out. If you know what to do, I'd be delighted to leave it to you!

I'm attaching the hacked file for the main part of the simplesearch plugin. My additions are clearly commented. With these additions, it searches the fields of each page as well as the other parts ta it already searched.

There's a limitation, or even a bug: it doesn't search the contents of 'list' fields. https://learn.getgrav.org/forms/blueprints/fields-available#the-list-field I tried to do that but haven't succeeded.

NB One can't send a PHP file so I've changed the extension to TXT. Change it back to php and use it in place of the standard issue to try it. If no luck let me know.

simplesearch.txt

Thomas

manuel-84 commented 6 years ago

@ThosG I've edited the latest version of the plugin (1.14.1) and I've added search through array/lists :) I'll make a pull request soon

simplesearch.php.txt

ThosG commented 6 years ago

@manuel-84 Fantastic! Thank you so much!

Now I don't suppose - (I'm pushing my luck here) - I don't suppose you could make 'ignore_accented_characters' work, could you? At present, it doesn't match café and cafe. Not because of the yaml setting; the internal code doesn't work properly. I know because I replaced the internal test for the yaml setting with a straightforward true and it still didn't work. Don't worry if that's too much, many thanks for what you've done.

manuel-84 commented 6 years ago

@ThosG I don't have any problem with ignore_accented_characters, but I think it's better to discuss this or other problems in a (eventually) new issue :)

ThosG commented 6 years ago

OK! Thanks again

manuel-84 commented 6 years ago

Added pull request #142

pixcod commented 6 years ago

@ThosG @manuel-84 this is just what I needed as I just now ran into this problem where I need the search to look at my custom fields. I am up-to-date with version 1.14.1 but not sure how I config SimpleSearch to look at my custom fields. Any thoughts?

manuel-84 commented 6 years ago

@pixcod we posted here the modified version of SimpleSearch and also the pull request from my repository where you can find the code you need

ThosG commented 5 years ago

I have attempted to create a pull request. Hop I've done it right ...