Advertisement:

Author Topic: Get custom field (meta) when a search is done  (Read 98 times)

elizabeth

  • Jr. Member
  • **
  • Posts: 80
Get custom field (meta) when a search is done
« on: September 07, 2019, 11:56:59 am »
Hi. I m trying to improve the search functionality and i want to display the meta custom fields when someone does a search at search page.

Example: I have 2 custom fields at cars category (Make, Model) that are searchable. When i search for items eg Mark:Audi Model:A6  then i get 4 results.

I need to display at the top of the search page something like that:

We found 4 results for: [Audi]  [A6] .

I tried
Code: [Select]
<?php if (Params::getParam('meta') <> '') { ?><div class="show-meta-fields">[<?php echo Params::getParam('meta); ?>]</div><?php ?>
but i m getting this :
Code: [Select]
We found 4 results for: [array]
Any help from expert devs?

@dev101, @WEBmods, @calibenhtuk ?

Thank you




Dimal

  • Full Member
  • ***
  • Posts: 135
Re: Get custom field (meta) when a search is done
« Reply #1 on: September 07, 2019, 12:39:41 pm »
It seems to be all women interested in the same things, more or less. Strange isn't it ?

https://forums.osclass.org/profile/?u=176849


 ;D

dev101

  • Osclass Hero
  • Hero Member
  • *
  • Posts: 2184
  • osclass.work
Re: Get custom field (meta) when a search is done
« Reply #2 on: September 07, 2019, 06:39:50 pm »
Hi, you cannot simply "echo" array, this is really basic, not only in PHP, but in practically any language out there. You need to see what's inside that array first and then "echo" values from it.

marius-ciclistu

  • issues
  • Hero Member
  • *
  • Posts: 1716
  • "BE GRATEFUL TO THOSE THAT SUPPORTED YOU"
Re: Get custom field (meta) when a search is done
« Reply #3 on: September 07, 2019, 07:39:58 pm »
Use var_dump() first to see the content of that array.

elizabeth

  • Jr. Member
  • **
  • Posts: 80
Re: Get custom field (meta) when a search is done
« Reply #4 on: September 08, 2019, 01:24:57 am »
Thanks guys for your suggestions.