Search Across Categories?

If you're a new user of AppGini, feel free to ask general usage questions, or look for answers here.
Post Reply
99er510
Posts: 3
Joined: 2015-06-02 23:19

Search Across Categories?

Post by 99er510 » 2015-06-03 00:08

I'm not very familiar with databases, so please bear with me if I'm not using the correct terminology.

I'm designing a database of equipment and software for a retro computer (TI-99/4A if you're interested... :D ti99db.org). It's coming along nicely - when you visit index.php, you get the link buttons for the categories that I've created: cartridges, hardware, software (floppy/cassette), and literature. Is there any way to provide a way to search through all of those categories? For example, some companies made products that fell into each category and if you searched for such a company, I'd want it to return with the items they made regardless of category. Or, if a user searched for 'spreadsheet' I would want it to return with results for spreadsheet programs in both the cartridge and software categories.

Is there a better way to do this? Am I looking at it wrong? Would the key be to use parent/children records? I did create a category for companies so that when you open one of those records, the products that they made are listed at the bottom. However, while that's a nice feature, I don't think that it's very obvious to users, and I don't want to create parent/child links for all of the duplicate fields in each category. I also considered using only one category for all items, but there are some fields that are particular only to each category, and I didn't know if there was a way to make some fields only show if a particular choice has already been selected (sort of like a sub-field).

Sorry if I blabbered on there- writing this got me thinking about possible options. I'm also wondering if the key might have to do with filtering...


Thanks,
Rich
99er.net

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Search Across Categories?

Post by a.gneady » 2015-06-04 10:28

You need to create a custom script for this that would display a search box and when search is submitted, would perform a search in each table then combine and list the search results. I'll try to write an example code for this soon.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

TheNoLifer
Veteran Member
Posts: 67
Joined: 2015-06-06 12:10

Re: Search Across Categories?

Post by TheNoLifer » 2015-06-08 03:05

I would find that 'global' search particularly useful too. Would be extremely grateful for some example code for this.

99er510
Posts: 3
Joined: 2015-06-02 23:19

Re: Search Across Categories? (Tables?)

Post by 99er510 » 2015-06-19 03:38

Yes- thank you! That example code would be great. I eventually hope to be able to pull records from all tables depending on the user, so learning how to do something like this would be really helpful.

Thanks,
Rich

H TARIK
Posts: 5
Joined: 2018-01-04 18:44

Re: Search Across Categories?

Post by H TARIK » 2018-02-14 17:51

Dear Ahmad and php pros.
I am new on appgini and i am not a php coder. I want to do some application for my business.
I really want to do search box for all tables in my application.
Any suggestion on this issue or if you done a script for this?
Thank you very much.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Search Across Categories?

Post by a.gneady » 2018-03-07 13:04

Oh! This thread has been open for quite some time now :) And I didn't get to write that tutorial ... so here is a gist I created on github to perform global-search: https://gist.github.com/bigprof/1dc6bc2 ... c48c2a4cc7

And here is some sample output:

Image
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

salemsaleem76
Posts: 19
Joined: 2016-04-28 09:52

Re: Search Across Categories?

Post by salemsaleem76 » 2018-03-08 07:33

Very Nice Ahmad but, why we could not have table header at the top of the page, If the data I am looking at is too long and in many tables I need to scroll too many times to find that.

H TARIK
Posts: 5
Joined: 2018-01-04 18:44

Re: Search Across Categories?

Post by H TARIK » 2018-03-08 16:13

Thank you Ahmad.

Panadu
Posts: 7
Joined: 2016-02-08 19:10

Re: Search Across Categories?

Post by Panadu » 2018-03-08 17:51

I have Problems with the global search.
I implemented the code and i found the Search-Button. If i search for anything, i got a error Message from SQL:

Unknown column 'house_viewport.' in 'field list'

SQL-Anfrage:
SELECT `house_viewport`.`` as 'PRIMARY_KEY_VALUE', `house_viewport`.`ID_ANZEIGE_OPTION` as 'ID_ANZEIGE_OPTION', `house_viewport`.`ANZEIGE_OPTION` as 'ANZEIGE_OPTION', `house_viewport`.`ANZEIGE_OPTION_BESCHREIBUNG` as 'ANZEIGE_OPTION_BESCHREIBUNG', `house_viewport`.`ANZEIGE_SORTIERUNG` as 'ANZEIGE_SORTIERUNG' FROM `house_viewport` WHERE 1=1 AND CONCAT_WS('||', `house_viewport`.`ID_ANZEIGE_OPTION`, `house_viewport`.`ANZEIGE_OPTION`, `house_viewport`.`ANZEIGE_OPTION_BESCHREIBUNG`, `house_viewport`.`ANZEIGE_SORTIERUNG`) LIKE '%1111%'

The above info is displayed because you are currently signed in as the super admin. Other users won't see this.

Can You help? All is correct in use, but the global search produces a error.

Thank You

User avatar
Jay Webb
Veteran Member
Posts: 80
Joined: 2017-08-26 15:27
Contact:

Re: Search Across Categories?

Post by Jay Webb » 2018-03-08 18:08

Great add on, worked for me, I have 4 large tables. Thanks a.gneady.
What we envision, we make happen.

Panadu
Posts: 7
Joined: 2016-02-08 19:10

Re: Search Across Categories?

Post by Panadu » 2018-03-09 09:25

SOLVED - Appgini dont created a column in my table. I added all manually, now its working.

Bye

David Soul
Veteran Member
Posts: 31
Joined: 2018-01-04 18:32
Location: Vancouver, Canada
Contact:

Re: Search Across Categories?

Post by David Soul » 2018-03-31 03:02

a.gneady wrote:
2018-03-07 13:04
Oh! This thread has been open for quite some time now :) And I didn't get to write that tutorial ... so here is a gist I created on github to perform global-search: https://gist.github.com/bigprof/1dc6bc2 ... c48c2a4cc7

And here is some sample output:

Image
I want to assign the link to a specific group rather than default to last group listed.
I tried appending this:
'table_group' => 'group-name’
To the code supplied for hooks/links-home.php but it “breaks” and the home page no longer displays any of the groups!

I have a similar problem if I try to add a stand-alone menu item for the search.

Is there a known reason why the code should not accept this table_group assignment?
David HC Soul

Core::AppGini 5.93
Plugins: Search Page Maker + Summary Reports + Mass update plugin
Bizzworxx: AppGini Helper JavaScript Library + AppGini Helper Detail View Plug-in + AppGini Helper pack
Utilities: Global Search utility

David Soul
Veteran Member
Posts: 31
Joined: 2018-01-04 18:32
Location: Vancouver, Canada
Contact:

Re: Search Across Categories?

Post by David Soul » 2018-03-31 16:12

I found code here that lets me put button on menu bar which allows functionality to call global search but like advice on using ‘table_group’ in array in “hooks/links-home.php’
Code from AppGini advice re menu bar “button”:
You can add links to the navigation menu by adding some JavaScript code to hooks/footer-extras.php
For example:
<script>$j(function(){ $j('nav .navbar-collapse').append( '<ul class="nav navbar-nav">' + '<a href="link-url" class="btn btn-default navbar-btn">Test Link</a>' + '</ul>' ); })</script>
David HC Soul

Core::AppGini 5.93
Plugins: Search Page Maker + Summary Reports + Mass update plugin
Bizzworxx: AppGini Helper JavaScript Library + AppGini Helper Detail View Plug-in + AppGini Helper pack
Utilities: Global Search utility

Melroy
Posts: 22
Joined: 2015-06-10 12:59

Re: Search Across Categories?

Post by Melroy » 2018-07-17 09:34

The global search page displays all fields for each record. This is not a problem for my groups who have full ownership rights but there is one group I restrict from seeing the detail view. Is there a way to select the fields to hide for all groups or better still, just for the one group I mentioned.

(I am using ver: 5.71)

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Search Across Categories?

Post by pbottcher » 2018-07-21 08:00

Hi,

what do you mean by restricting to see the datail view. The data is catched from the tables. Do you want to exclude tables from the search?
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Melroy
Posts: 22
Joined: 2015-06-10 12:59

Re: Search Across Categories?

Post by Melroy » 2018-08-08 10:06

Hi pböttcher,

My apologies for not responding to your reply earlier.

I guess what I am trying to say is that I want to set up the global search to search across all tables but only in those fields displayed in my table view and not the detail view which might contain private information.

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Search Across Categories?

Post by a.gneady » 2018-08-08 12:52

Hmm ... one possible way to do this is to insert some code directly after line 29 to filter out the private fields from $results array. So, you could add a check on the user group and if it matches some specific group, loop through the $results array and unset the elements representing the private fields.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Melroy
Posts: 22
Joined: 2015-06-10 12:59

Re: Search Across Categories?

Post by Melroy » 2018-08-08 13:16

I can probably make life a little simpler by restricting all groups from seeing the detail view fields. The priority for me is for users to search the 'title' and 'description' fields in the table view. A pdf or image link, provided in the table view would then take them to a relevant document/image. That presumably means I would only need to filter out the fields in the details view? My problem is (as always) that I am not proficient in coding so will need help on that.

xbox2007
Veteran Member
Posts: 129
Joined: 2016-12-16 16:49

Re: Search Across Categories?

Post by xbox2007 » 2023-11-03 22:36

thanks a lot Mr Ahemd its very nice
but i would like ask if i can choice single table only ?
also
how if i want search on two or three table not all tables

thanks a lot

User avatar
a.gneady
Site Admin
Posts: 1281
Joined: 2012-09-27 14:46
Contact:

Re: Search Across Categories?

Post by a.gneady » 2023-11-07 16:52

xbox2007 wrote:
2023-11-03 22:36
thanks a lot Mr Ahemd its very nice
but i would like ask if i can choice single table only ?
also
how if i want search on two or three table not all tables

thanks a lot
One way to do this is to change line 89 of the script from:

Code: Select all

$tables = getTableList();
to:

Code: Select all

$tables = [
    'table1' => [], 
    'table2' => [],
    'table3' => [],
];
The above would limit search to table1, table2 and table3. Of course, replace those by the actual table names in your case.
:idea: AppGini plugins to add more power to your apps:
  • DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
  • Mass Update plugin: Update multiple records at once and improve your workflow efficiency.
  • Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.

Post Reply