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?
eg
- 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?
Cheers
luis
13 replies
-
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:
contains(text('Choice'), "Crime")
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
thanks
-
Hello Luis,
I'd be curious to know how you did this with arrays?
Do you mean that you're traversing this array everytime you do anything?
-
I need a tag search and a tag manager too
-
Hi chaps :-)sorry for the late reply :-(
Here is what I have done
PART 1
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)]That's it.
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...
PART 2
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...
-
Add-on (in case is not apparent) - in the above code 'Genre Tags' is the Choice field in the Books DB where the user defines the Tags
-
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.
BR
-
Hi luis, can show or share a db sample of your code? thanks. have a nince day.
-
i have not understanding your line :
(select Books)[testx(concat(sort(chosen('Genre Tags'))), tagRegExpress)]
what make your function : testx
-
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
luis
-
nice luis, but what dont use function contains("my string for search","for")= true
-
hi
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
- Düsseldorf
- 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
-
ok i understand now your utility for regex
Content aside
- 4 yrs agoLast active
- 13Replies
- 1984Views