[development] DEP - cascading variable system

Gerhard Killesreiter gerhard at killesreiter.de
Wed Nov 30 20:12:16 UTC 2005


Michelangelo Partipilo wrote:

> What about module settings per user? Let's say I write an Album Module 
> and I want each user to be able to select the way his gallery should 
> be presented, or the theme that should be used for it. Of course I 
> could put these on a DB table, but that wouldn't that just add more 
> tables and module logic? These wouldn't be needed if this is implemented.
>

Hi, glad you are back.

it is a bad idea because you would have a variable for each user. On 
Drupal.org it would mean 40000 variables. Those would be (with the 
current design) loaded per page view and maybe break you php memory limit.

The current recommended way of adding user variables is to

a) store them in the user object. This way they will end up in the 
user.data column.
Example: block.module
pro: easy to do
contra: hard to get the setting for all users as it is in a serialized 
array inside user.data

or

b) make a db table for this and store it yourself
pro: easy to get all users with setting "foo"
contra: needs a little bit more work

There is also option c):

add to the $_SESSION variable

pro: easy to do
contra: only lasts for the current session


Cheers,
    Gerhard


More information about the development mailing list