Saturday, April 20, 2013

Drupal 7 drupal_goto options query and fragment

Lets we take example url as " product?a=1&b=2#bottom ". Then you should make drupal_goto as below.

drupal_goto($path = '', array $options = array(), $http_response_code = 302)

Explanation as per example url
$path = 'product'
$options = array( 'query' => array('a' =>1,'b'=>2), 'fragment' => 'bottom', );
$http_response_code is optional (described below).
drupal_goto($path ,$options); Will produce " product?a=1&b=2#bottom "
More info about response code,

$http_response_code: (optional) The HTTP status code to use for the redirection, defaults to 302. The valid values for 3xx redirection status codes are defined in RFC 2616and the draft for the new HTTP status codes:

301: Moved Permanently (the recommended value for most redirects).
302: Found (default in Drupal and PHP, sometimes used for spamming search engines).
303: See Other.
304: Not Modified.
305: Use Proxy.
307: Temporary Redirect.

No comments:

Post a Comment