0

I am trying to pass the variables from one page to another in Drupal 7. Since in Drupal 7 we do not create the php file as such the content of the page gets saved as a plain text in DB, no files get created, so GET/POST are out of the solution.

How can I do this?

Jeffrey Bosboom
  • 13,313
  • 16
  • 79
  • 92

2 Answers2

0

Content is saved in database, but every content is defined in some content type. And for every content type you can have different template file. Inside that template file you can put your php code reading GET/POST, or what ever.

So, you can use the usual way and read parameters from template, do what ever you want with them.

MilanG
  • 6,994
  • 2
  • 35
  • 64
  • Thanks for the reply. I would like to further explain the problem, I am having a _basic page_ whose body contains my PHP code. Now I am trying to open modal window/new page here on selecting the data from the table in the page. The modal window/new page must have the selected data information in order to process it. For passing the variable I looked for [link](http://jsfiddle.net/Au9tc/605/), which didn't worked for me. – Vivek Kumar Tamta Mar 27 '15 at 05:37
  • I don't get it really. If it's modal, it's just a css/js trick. Content is there even that modal part is shown - preloaded, right? – MilanG Mar 27 '15 at 16:29
  • And if not - you can use AJAX call, pass some id and get back JSON, HTML, what ever and. – MilanG Mar 27 '15 at 16:31
0

One way is to use variable_set() to save the value to database and variable_get() to retrieve the value from database.

To save the value:

variable_set('my_variable_unique_id', 'the value to be saved.');

To read the value back:

$myVariable = variable_get('my_variable_unique_id', 'default value in case could not find a saved value for the variable.');
halfer
  • 19,824
  • 17
  • 99
  • 186
Muhammad Reda
  • 26,379
  • 14
  • 93
  • 105
  • Thanks for the reply. I would like to further explain the problem, I am having a _basic page_ whose body contains my PHP code. Now I am trying to open modal window/new page here on selecting the data from the table in the page. The modal window/new page must have the selected data information in order to process it. For passing the variable I looked for [link](http://jsfiddle.net/Au9tc/605/), which didn't worked for me. – Vivek Kumar Tamta Mar 27 '15 at 05:36