Trying to make dynamic filters
-
Hi Peter,
I was trying to filter data based on a dynamic hyperlink. That didn’t seem to work, so I am going a few steps back and trying the various filter options that I have seen listed in your documentation and here in the forum.
My data is music based, simplified lets say artists and tracks. I have an artists table and a tracks table. Each track has 1 artist and each artist has 1 or more tracks.
In my artists table there is id, artist_name
In my tracks table there is id, id_artist, track_nameMy goal is to have publication showing a list of artists, with a link to ‘view all tracks’ for that artist.
Step 1. I can define a WHERE clause in my Data Publisher entry for the tracks table (id_artist=”9″). This works – and if I embed the shortcode [wpdataaccess pub_id=”5″] then I do see a list of tracks for artist 9 when I visit the page:
https://mysite.com/tester/Step 2. I tried to add the filter inside the shortcode, like this:
[wpdataaccess pub_id=”5″ filter_field_name=”id_artist” filter_field_value=”9″]
So, visiting https://mysite.com/tester/
This gives no results (I did remove the previous WHERE from the publication).Step 3. Following your comments here (https://wpdataaccess.com/2020/07/09/add-user-input-filter-to-where-clause/) I tried to add a query variable to provide the filter:
shortcode [wpdataaccess pub_id=”5″]
https://mysite.com/tester/?wpda_search_column_id_artist=9
This returns all of the records, so no filtering.Step 3 would provide the best solution (if it would work) as ultimately I want to add a dynamic hyperlink to the artists table using the data explorer, so that I can have a ‘view tracks’ link next to reach artist.
If Step 2 would work then I could probably create a WordPress page to retrieve query variable data, then run a do_shortcode() in php adding the filter tags in the shortcode.
I have an additional question – can you confirm if these filters are applied when SELECTing from the DB, so only relevant data is retrieved.
I would welcome any advice as to how to best implement this dynamic filter functionality.
Thanks,
Mark
- The topic ‘Trying to make dynamic filters’ is closed to new replies.