Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I have a front page with a views-exposed-form build with "Views".
I need to get from the user a town value (from a taxonomy) and then go to another view page (accueil) and change the value of the filter to get a number not a name value.
it works like this
on submit front page here is the url :
http://www.mysite.fr/front?localite=Sauve
And I need
http://www.mysite.fr/accueil?localite=12225
12225 is the nid of the town Sauve
I have build a module with hook form alter :
//page front
if($form['#id'] == 'views-exposed-form-front-page') {
$form['#action'] = '/accueil';//it change the URL on submit but I can't add the argument
//function to get the tid of the town taxon
$commune = $form_state['input']['localite'];
$taxonomy_id = taxonomy_get_term_by_name($commune);
if(!empty($taxonomy_id)) {
$tid = -1;
foreach ($taxonomy_id as $taxonomy_item) {
$tid = $taxonomy_item->tid;
}
}
if (empty($taxonomy_id)) {
$tid='';
}
//dpm($form);
}
How can I rebuild the url now with the tid like this?
$form[argument]=$tid;
Comments
Comment #1
saurabh.dhariwal CreditAttribution: saurabh.dhariwal at AddWeb Solution Pvt. Ltd. commentedHere's the work around.
Hope this helps you.
Thanks!
Comment #2
renatogComment #3
renatogHi guys.
Thank you very much @saurabhdhariwal. It's possible using form_alter
@zorax, You did it?
If have any question about it please comment for us.
Thank you very much.
Regards.