1

I have seen this question asked over on DO and here, but there doesn't seem to be a clear answer.

How to create a path alias with a query string in the target?

I need to able to send a query string when someone clicks on a Taxonomy Tag.

So, I set my tags such as Things-To-Do/All/[term:name]/?shs_term_node_tid_depth=[term:tid]

Which encodes the string to /Things-To-Do/All/arts-culture-history/%3Fshs_term_node_tid_depth%3D612

Which does pull up my view, but of course, doesn't filter.

I have tried creating a custom module, as well as using global redirect, but no luck.

Is this simply not possible? Can I stick something in View Pre-render or something that will unencode the string before it renders.

I have been hitting my head against this problem for a while now and really don't know where to turn.

I should point out that the above answer 'works' but not really with dynamic content.

1 Answer 1

0

Well, I finally figured it out.

    function cin_rd_init(){

    //first I see if this is a taxonomy page
    if (arg(0) == 'taxonomy') {

    //then I get the termID from the argument   
    $termid=arg(2);
        $newterm=taxonomy_term_load($termid);

        if(!empty($newterm)){
        $thetermname=str_replace(' ','-',$newterm->name);
        $thetermid=$newterm->tid;   
        $newtermvid=$newterm->vid;

        //Next I check the vocabularyID to see if it should be redirected
        //Important, I also check to see if my parameter string is set already so I don't have an endless redirect.
        if($newtermvid==18 && (!isset($_REQUEST['shs_term_node_tid_depth']))){  
        drupal_goto('/Events/All/'.$thetermname.'/', array('query' => array('shs_term_node_tid_depth' => $thetermid)));
        }
        //I can change the destination and query string depending on the vocab I am using
        if($newtermvid==19 && (!isset($_REQUEST['features']))){ 
        drupal_goto('/Events/All/'.$thetermname.'/', array('query' => array('features[]' => $thetermid)));
        }
} //not empty
} //end if taxonomy
} //end function

So now, anyone who goes to a taxonomy term page will either go directly to the term page, unless the term belongs to either of these vocabularies.

If so, then it will redirect those with a query string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.