Any comments regarding default variable namespaces?&nbsp; <br>Right now I have a lot of long variable names just to avoid clashes with my own stuff.<br><br>variable_get(&#39;my_module_name_my_variable_name_var&#39;, MY_DEFAULT_VALUE);
<br><br>I was wondering if we should have variables within their own module namespaces.<br>Sort of like local module variables (stored in the db of course) that would be guarrenteed<br>unique???<br><br>Also, a side benefit of namespaces might be something like this:
<br><br>$vars = variable_get_array(&#39;my_module_name&#39;);<br><br>which could load all the variables for a module with one db call.<br><br><br><br><div><span class="gmail_quote">On 5/3/07, <b class="gmail_sendername">Earnie Boyd
</b> &lt;<a href="mailto:earnie@users.sourceforge.net">earnie@users.sourceforge.net</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Quoting Gabor Hojtsy &lt;<a href="mailto:gabor@hojtsy.hu">gabor@hojtsy.hu</a>&gt;:<br><br>&gt; Hi,<br>&gt;<br>&gt; To be able to translate variables to multiple languages in Drupal<br>&gt; nicely, we would need a small conceptual change, which would benefit
<br>&gt; all of the Drupal developers, so I am posting the call here in hopes<br>&gt; we have someone or a small group to pick this task up.<br>&gt;<br>&gt; **We need a central place to define variable defaults**<br>&gt;<br>
<br>At the top of the module:<br><br>&lt;?php<br>define(&#39;MY_DEFAULT_VALUE&#39;, t(&#39;my_default_value&#39;));<br>?&gt;<br><br>&gt; Simple! Now whenever you need a variable, you do<br>&gt;<br>&gt;&nbsp;&nbsp; variable_get(&#39;my_fine_var&#39;, &#39;my_default_value&#39;);
<br>&gt;<br><br>Then in the code:<br><br>&lt;?php<br>variable_get (&#39;my_find_var&#39;, MY_DEFAULT_VALUE);<br>?&gt;<br><br>&gt; The problem with this is that you need to repeat this multiple times,<br>&gt; and of course there is a chance you need to modify it later on, so
<br>&gt; you need to find all places a variable is used. Not good. Remember<br>&gt; the changes from bluemarine to garland, we have been fixing<br>&gt; theme_default errors for days, finding out places where the variable<br>
&gt; was used...<br>&gt;<br><br>I then only have one place to edit.<br><br>&gt; So we need a central place to define variable defaults. For Drupal 6<br>&gt; this is enough now:<br>&gt;<br><br>The central place is at the top of the module with a define statement.
<br><br>&gt;&nbsp;&nbsp; hook_settings() {<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; return array(<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#39;my_fine_var&#39; =&gt; &#39;my_default_value&#39;,<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp; );<br>&gt;&nbsp;&nbsp; }<br>&gt;<br>&gt; Have fun with naming it hook_settings(), as far as I see, it is an
<br>&gt; appropriate name, and not taken at the moment :) So Drupal can do a<br>&gt; module_invoke_all() on hook_settings() and collect defaults to all<br>&gt; variables from the modules defining them. It gets easier and shorter
<br>&gt; to use variables:<br>&gt;<br>&gt;&nbsp;&nbsp; variable_get(&#39;my_fine_var&#39;);<br>&gt;<br><br>variable_get(&#39;my_fine_var&#39;, MY_DEFAULT_VALUE) is simple enough.&nbsp;&nbsp;I<br>don&#39;t understand why we would need to add this complication and
<br>overhead.<br><br>Earnie<br></blockquote></div><br><br clear="all"><br>-- <br>-&gt; JV