Advertisement:

Author Topic: Custom fields can not search by filters!!!  (Read 1179 times)

abc500x500

  • Jr. Member
  • **
  • Posts: 96
Custom fields can not search by filters!!!
« on: April 07, 2018, 10:42:28 pm »
Hi.
I use Osclass 3.7.4 without permalink.

Custom fields can not search!!!

I see those work in oc.3.6.1 !

How can solve this problem?
thanks

abc500x500

  • Jr. Member
  • **
  • Posts: 96
Re: Custom fields can not search by filters!!!
« Reply #1 on: April 07, 2018, 11:13:39 pm »
For example we have a selection fields , when search that fileld in 3.7.4 it do not show true result but in 3.6.1 it show true result.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom fields can not search by filters!!!
« Reply #2 on: April 08, 2018, 12:06:56 am »
Enable permalinks for them to work.

I did not investigate why they don't work without permalinks.

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom fields can not search by filters!!!
« Reply #3 on: April 08, 2018, 01:36:01 pm »
Hi,

Try backporting public function extractParams($uri = '') from 3.6.1 as described here:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg152305/#msg152305
 
But there's still an issue with spaces and other characters, see this patch:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg160878/#msg160878

Regards

abc500x500

  • Jr. Member
  • **
  • Posts: 96
Re: Custom fields can not search by filters!!!
« Reply #4 on: April 13, 2018, 08:11:27 pm »
Hi,

Try backporting public function extractParams($uri = '') from 3.6.1 as described here:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg152305/#msg152305
 
But there's still an issue with spaces and other characters, see this patch:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg160878/#msg160878

Regards
Thanks teseo.
I do not want use permalinks.
are there solutions (2 link) for solving using permalinks or otherone ?

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom fields can not search by filters!!!
« Reply #5 on: April 14, 2018, 02:12:16 pm »
That solves the problem when permalinks aren't enabled.

Regards

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Custom fields can not search by filters!!!
« Reply #6 on: June 01, 2018, 10:53:11 am »
From my experience that solution in the other thread regarding rewrite.php works, but only when I enter command line searches and like so - /index.php?page=search&meta[2]=query&sCategory=1 but does not work if I enter words in the custom search fields in sidebar.
« Last Edit: June 01, 2018, 11:34:28 am by Resta »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Custom fields can not search by filters!!!
« Reply #7 on: June 01, 2018, 01:59:49 pm »
Hi,

Try backporting public function extractParams($uri = '') from 3.6.1 as described here:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg152305/#msg152305
 
But there's still an issue with spaces and other characters, see this patch:

https://forums.osclass.org/themes-26/custom-fields-is-not-searching/msg160878/#msg160878

Regards

Hi teseo,
the links/topics seems to be removed. Can you repost this here? What kind of issue is it? Maybe there should be a PR made.

edit: I have done a quick test, it seems that custom fields are ignored/reset in search for some reason without permalinks. This is definitely a bug...

issue: https://github.com/osclass/Osclass/issues/2259

Thanks
dev101
« Last Edit: June 01, 2018, 02:41:29 pm by dev101 »

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1652
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Custom fields can not search by filters!!!
« Reply #8 on: June 01, 2018, 02:23:55 pm »
@dev101, yes it is:)

I'm curious, why should someone use the site without permalinks?

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Custom fields can not search by filters!!!
« Reply #9 on: June 01, 2018, 03:57:04 pm »
I have updated issue @ github:

official fix:
https://github.com/osclass/Osclass/pull/2261/files

Please give it a test and see if this fixes the issue with CFs and permalinks off. Tested with Osclass 3.7.4 (latest version).

This is a preliminary solution, seems to be working fine on my end, but it needs to be revisited and approved by someone from Osclass Team (so keep that in mind).

I still don't know what is teseo's proposal about this, we can compare them and pick the best approach to fix this.

. . .

I'm curious, why should someone use the site without permalinks?

It does not really matter why, there could be various reasons, one being default mode after Osclass installation is good enough on it's own, permalinks add another layer of complexity (and are usually easier to become buggy).

edit: related recent forum topic: https://forums.osclass.org/general-help/osc_rewrite_enabled/

. . .

Regards
dev101
« Last Edit: June 08, 2018, 12:57:28 pm by dev101 »

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom fields can not search by filters!!!
« Reply #10 on: June 02, 2018, 01:42:23 pm »
Hi teseo,
the links/topics seems to be removed. Can you repost this here? What kind of issue is it? Maybe there should be a PR made.

Hi,

Don't know why you can't see these messages, they are there... ???

Anyway, the messages are not mine, the first one recommended backport of 3.6.1 function, and the second one:

Hello everybody,

The change made solves the problem but creates another. when you search with spaces or special characters, the url is badly coded and the search does not work. The code must be corrected as follows (see last line ):

public function extractParams($uri = '')
        {
            $uri_array = explode('?', $uri);
            $length_i = count($uri_array);
            for($var_i = 1;$var_i<$length_i;$var_i++) {
                if(preg_match_all('|&([^=]+)=([^&]*)|', '&'.$uri_array[$var_i].'&', $matches)) {
                    $length = count($matches[1]);
                    for($var_k = 0;$var_k<$length;$var_k++) {
                        Params::setParam($matches[1][$var_k], urldecode($matches[2][$var_k]));
                    }
                }
            }
        }


This worked but meta parameters would show duplicated in the URL, I have tested your proposal and seems to be working fine.

Regards

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Custom fields can not search by filters!!!
« Reply #11 on: June 02, 2018, 02:17:44 pm »
Hi teseo,

Thanks for your reply!

Yeah, above links do work now, however, yesterday I received page/topic missing page, so maybe they were restored in the meantime, don't really know what happened, as I've tried several times to make sure. update: for some strange reason I can access those links if I'm logged out of the forum, but not when I'm logged in (!?).

Yes, the proposed solution does work for vanilla Osclass, my mistake was that I tested this on my dev version on a different server, which has some differences, and that patch does not work well there. I had to make a different version for it to work, but the point is it got me stranded in the wrong direction that this was related to server/environment, instead of Osclass 'version'. I'll have to revisit my own code and find out from where some 'ghost' extra parameters come from, but for the official Osclass version that solution should be fine.

Thanks again!
Regards
« Last Edit: June 02, 2018, 02:46:11 pm by dev101 »

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2155
  • osclass.work
Re: Custom fields can not search by filters!!!
« Reply #12 on: June 02, 2018, 03:29:10 pm »
Hi teseo,

As apparently I have no ability to access, read and post in that topic as a user, can you post a link there to this discussion here?

Rolling back that code alone is not enough (there are other places that needs changes as well in that case) and, in fact, not recommended.

They should try the above fix instead and see if that solves the search problem (it should).

Regards
dev101

Resta

  • Sr. Member
  • ****
  • Posts: 345
Re: Custom fields can not search by filters!!!
« Reply #13 on: June 03, 2018, 12:59:19 am »
Another issue that has been mentioned before by others is that the custom fields DO NOT SHOW on the sidebar except for the main category I think and I don't know if this is how it is by default - I don't know the specifics but on most search pages for me it the custom fields do not show on the sidebar (permalinks disabled). 

For this reason, one of the things I have been trying to find out is how to make my own advanced search form like creating a new search form on a custom page and get rid of the sidebar, that way I can create or add the custom fields that I think needs to be searchable, but I have not been able to find how to do that.  Thanks!

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Custom fields can not search by filters!!!
« Reply #14 on: June 10, 2018, 03:25:28 pm »
Hi @dev101, sorry for the delay.

I have updated issue @ github:

official fix:
https://github.com/osclass/Osclass/pull/2261/files

Very nice :)

I've added a link to your message in that thread, don't know what might be happening to you ???

Thanks, regards