grav-plugin-simplesearch icon indicating copy to clipboard operation
grav-plugin-simplesearch copied to clipboard

how to search in custom fields?

Open manuel-84 opened this issue 7 years ago • 16 comments

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?

manuel-84 avatar Nov 13 '17 09:11 manuel-84

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

ThosG avatar Dec 29 '17 07:12 ThosG

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

manuel-84 avatar Dec 29 '17 09:12 manuel-84

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.

ThosG avatar Jan 08 '18 21:01 ThosG

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

rhukster avatar Jan 08 '18 21:01 rhukster

I see. OK, will do tomorrow. Thanks

Thomas

On 8 Jan 2018, at 21:30, Andy Miller [email protected] 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 avatar Jan 08 '18 21:01 ThosG

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 [email protected] 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 avatar Jan 09 '18 13:01 ThosG

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

manuel-84 avatar Jan 11 '18 15:01 manuel-84

@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

ThosG avatar Jan 12 '18 09:01 ThosG

@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

manuel-84 avatar Jan 12 '18 15:01 manuel-84

@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.

ThosG avatar Jan 12 '18 15:01 ThosG

@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 :)

manuel-84 avatar Jan 12 '18 15:01 manuel-84

OK! Thanks again

ThosG avatar Jan 12 '18 15:01 ThosG

Added pull request #142

manuel-84 avatar Jan 12 '18 19:01 manuel-84

@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?

pixcod avatar Jan 25 '18 22:01 pixcod

@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

manuel-84 avatar Jan 26 '18 11:01 manuel-84

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

ThosG avatar Jul 24 '19 16:07 ThosG