12 Posts
Manish
5 years ago
2
Topic

Hello

I'm using the Query plugin that lets me create a Query field on my List & Search. I have a hidden field with ID 'id_number' which I'm trying to use in my query. When I check the Page Source(Ctrl+U on Chrome), the hidden field has the correct value of id_number which is '22865'.

The part of my Query is-

WHERE [MATCH]p.pid||$cck->getValue('id_number')[/MATCH] AND (ban_reason in ("", "active"))

When I print this query out using the Debugger, the Query is using the literal value and querying the above as follow-

(p.pid LIKE '%$cck->getValue(\'id\_number\')%') ....and not something like (p.pid LIKE '%22865%')

I also tried using $fields['id_number']->value but it still queries it incorrectly.

Should I not use $cck->getValue('id_number') to get the value of the hidden field in the query? Or is there something other than this that I need to use?

Get a Book for SEBLOD
5 years ago
1
Level 1

Hi Manish

If you refer to this plugin (https://www.seblod.com/resources/tutorials/using-the-search-query-field-plugin) it's true it doesn't allow to fetch values from other fields present on the page.


This is why we had to developp a quite modified version of this plugin to be able to add some PHP code inside. This way we can retrieve anything we want


But I would prefer Seblod proposes an enhanced version of their plugin

thanks


cyril



5 years ago
0
Level 2

Another better way to achieve this would be to use the BeforeSearch code field and generate the query  through PHP/SQL code as a string to inject in the search query field. 

Get a VIP membership