Loading...
 
Features / Usability

Features / Usability


CustomSearch landing url pre-filled with search criteria

posts: 8357 Israel

I have already used the tracker filtering URL parameter successfully like:

tiki-index.php?page=payments-list&default[tracker_field_paymentsMonthPaid]=January

(The month is even inserted from a calculation to insert the current month... neat (!)

This is on a Tiki22 with a dropdown filter (select)


I’m trying to set a bit of the same on another Tiki22 but with radio buttons.

{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="vente" _group="20"}
{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="location" _group="20"}


So I have 2 URL:

tiki-index.php?page=biens&default[tracker_field_biensAC3TypeDOffre]= vente
tiki-index.php?page=biens&default[tracker_field_biensAC3TypeDOffre]=location

Tried also

biens?default~tracker_field_biensAC3TypeDOffre=vente
biens?default~tracker_field_biensAC3TypeDOffre=location


But no matter what, only the second filter (the last) is working (and applied).
I checked what happen when no radio button is selected previously it ends with the second filter.

Any ideas on how to do this ?

Screen Shot 2021 02 25 At 12.17.00

posts: 126729 United Kingdom

Hi Bernard

Quite a few field types don't work, user selector and date ranges i know about, wouldn't be surprised if radio buttons were also not "supported".

However, there is a way round this, you can use the URI fragment on almost all field types. Enable the "Use custom search JavaScript file" on the plugin customsearchjs="1" and do the search you want. The URL should change to something like:
example.tiki/search#type=pdf (not sure what radio buttons will look like)
Note, you need to give your input an id, here it would be id="type" - you can then use that url to preset the field (hopefully?)


posts: 8357 Israel

Thank you Jonny for your help. ♥️

Based on you comment and the doc at http://doc.tiki.org/PluginCustomSearch#Radio_button_example: I modified my code and added the "customsearchjs" parameters.

{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="vente" id="type" _group="20"}
{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="location" id="type" _group="20"}


Then:

tiki-index.php?page=biens#type=location
tiki-index.php?page=biens#type=vente

or

biens#type=vente

It just load the page with nothing selected.
I have the feeling I’m missing something.
(not sure what radio buttons will look like) ?? What do you mean

posts: 126729 United Kingdom
Bernard Sfez / Tiki Specialist wrote:
(not sure what radio buttons will look like) ?? What do you mean


You can't have more than one element with the same id, so the radio buttons will need different ones... and i don't have any suitable tests set up or time to experiment now, sorry.


posts: 8357 Israel

Thank you Jonny ! 🙏
So far no luck but I’ll try tomorrow with fresh brain. ;-)


posts: 126729 United Kingdom

Hi Bernard again

As it would happen i had to fix a client's search page with radio buttons on, so i experimented with the id's and found this worked (for example)

In the form template
articles: {input _filter="content" type="radio" _field="tracker_id" _value="11" _group="type" id="type_article"}
organizations: {input _filter="content" type="radio" _field="tracker_id" _value="1" _group="type" id="type_org"}
events: {input _filter="content" type="radio" _field="tracker_id" _value="6" _group="type" id="type_event"}


So the url for events would be /search#type_event=1

HTH mrgreen

posts: 8357 Israel

Ha ha ha dear Jonny great you could test this.

It appears that I tried something similar to the sample code you posted on my local with Firefox and it didn’t worked for me. But know I know what should work, thank you very much for this !

Tomorrow I will on a real server. (I’m not using elasticSearch)


posts: 8357 Israel

Tried on a real server, no joy...

In the search form:

{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="vente" _group="type" id="type_vente"}
{input _filter="content" type="radio" _field="tracker_field_biensAC3TypeDOffre" _value="location" _group="type" id="type_location"}


(I looking in a single tracker to filter items: vente or location)

search#type_vente=vente