Friday, February 4, 2011

Methods to Pass Values through URL in Drupal

Two Ways of Passing Values through URL are mentioned here for Drupal

I) goto

drupal_goto('sample/'.$xyz.'/'.$abc.'/'.$lmn);

where
  • sample is the page where u have to navigate
  • $xyz,$abc,$lmn are the variables you are passing to that page.
Points to remember

  1. You can either store values in variable and send them or do it directly by mentioning the value instead of the variable there
  2. You can also use this to simply navigate to same page or some other page even without using variables(make sure u don't use slash at the end)
eg : drupal_goto('sample');

II) a href (traditional method)


  1. <@ href=\'?q=sample / ' . $abc.'\'>
  2. Update General Details
  3. < / @ >
where
  • @ means 'a'
  • $abc is an variable
  • User can give his own wordings instead of "Update General Details"
  • When User Clicks on Update General Details , the page will be navigating to the sample page with the value.
Difference Between The Both I & II

  • goto gets executed with the control reaches there.
  • a href get executed only when the user cliks on it

-------------------------

https://amzn.to/44VdtxB


No comments:

Post a Comment