Searching for Tags and successive subsets of Views
Hi, any ideas please guys on the best way to do the following?
lets get as example a database of books. The books may have multiple tags (eg Horror, Crime, True Crime, Fiction, etc)
I have a multiple choice for the assignment of Tags (yes, one of the things I would lile to have is to be able to populate the nultiple choice from a table.... :-)... I read several times now it is a request)
So now I wnat to give the possibilty to successively show the Books corresponding to the set of Tags I select eg
I select Crime -> I see in the view a set of boosk with that tag
I select Fiction and now the view changes to the books that have "Crime" AND "Fiction"
and so on...
(as a bonus I also want to show the subset of Tags "remaining" in the View e.g. after selecting Crime I see that there are books with tags "Fiction", "True Crime", "Science", "Psychology", etc)
What is the best way?
- create a new view from scratch with the conjunction (AND) of the successive chain of Tags?
- can we refine a View ? eg subset of an exisitng view?
One approach would be to create a view (table) for each tag. Then have the views switch from visible to not visible based on the contents of the Choice popup field.
For example, if the Choice field has a value of "Crime", and the Crime view "display field only if" property is set to:
then it will become visible (true) when Crime is selected from the Choice pop-up. Repeat for the other tag views.
Hi, thanks for replying.
this would not do it as needed, as it chceks for a single Tag and not the combination.
I implemented a solution based on arrays - one stores the Filter Tags the users defines, and then I do test for each book if the set of tags (for each book) is at least the same as the "Filter".... and if yes I enter the ID... and then present the final result.
It works well but I am not sure it there is a more effective way... eg each time the user adds or removes a new Tag I simply "re-do" the query
It is very fast... but as mentioned I was interested to know if there were other manipulations
Hi chaps :-)sorry for the late reply :-(
Here is what I have done
In the database the user selects the tags out of a multichoice list ('Tags Filter')
then I created a View with the code:
let sTags := sort(chosen('Tags Filter'));
let tagRegExpress := ".*" + replace(concat(sTags), ",", ".*") + ".*";
(select Books)[testx(concat(sort(chosen('Genre Tags'))), tagRegExpress)]
A couple of where I spent some time doing trial and error and the reason for some _sort_:
- the chosen function returns the items ordered by the *numerical* id in the choice... so if you add itemss ot the list and then reorder, they would come after the existing ones... and this would make the comparison in the Select void
- instead of splitting an array in components and then adding the ".*" expression and then joining it all, I used the 'replace' function.
The reason you need this is for cases when for instance you are looking for "Biography" + "Reportage" and the book has Biography,History,Reportage...
I too wanted to have a dynamic way to fill the drop down list with the Tags... eg I wanted to have a DB for Tags (also reading them from an external source)
This apparently is NOT possible in NINOX... seems to me really a shame as this certainly can help to create cool implementations
So in my implementation I have to manually add/remove/change the Multiple Choice...
Thanks, Luís, for the heads up.
Cool way of resolving Ninox's limitation. I too agree that the MC field should be programmatically changed. Don't see why the coding gods don't implement this and if it is the roadmap at all.
Anyway, regexp is something I have to look into because I never used it before.
Now I'll go and test this too see it in a working environment.
hi Robert, I will try to get a sample of the DB...
regarding your question:
testx is a search in a string (the one in the first argument... also in my case the concatenation of all 'Genre Tags' that were selected) using a *regular expression* ...(that's the second argument)
For Regex testing you can go here: https://regex101.com
because the search is not flexible... for instance you cant look for matches *inside* the string and following patterns... ; regular expressions can do that: if I want to find the name of a german city eg Düsseldorf... it can be written as
- Duesseldorf (as in german the ü can be repalced by ue..)
- Dusseldorf (if someone wrote it in english)
so to use "normal" string searchs it is a pain... (and not to forget that may be someone wrote it with small cases etc etc etc