Previous Thread
Next Thread
Print Thread
Rate Thread
#245917 05/11/2003 9:14 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
I want to put in an array as value of a config option, but this seems to muck up the editconfig script as it shows 'Array' as value instead of the array. Any ideas how to get around this? I really want an associative array for easy access.

At the moment it looks like this:
Code
$config['groupcolor'] = array(<br />    "5" => "Normal",<br />    "6" => "#FF6600",<br />    );<br />


Or is this something I should report as a bug?

Sponsored Links
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
I would be surprised if the config editor could handle that. I think it treats all the $config values as scalars.

Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
OOH - I dunno the answer - but I kind of like your theory about it... colors for groups.

Can something like this work?

$config['groupcolor'][5] =

Last edited by JoshPet; 05/11/2003 9:21 PM.
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Yeah, I could do it that way I guess. A bit more to write though, but that shouldn't matter. Thanks.

I've been doing a mod on request to change color and/or title based on group which I will be able to release soon for your enjoyment.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
It seems I spoke to soon, since that notation also gives an array, the same problem arises.

I really don't want to have a comma separated value and split it, it's not very clean and easy to break.

Sponsored Links
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
No, it seems it doesn't, but here is a quick hack to make it handle one level of arrays.

Change these lines in admin/editconfig.php:
Code
<br />   while (list($key,$value) = each($config)) {<br />      if (!ereg("-$key-",$knownkeys)) {<br />         $extras .= "\$config['$key'] = '$config[$key]';\n";<br />      }<br />   }<br />


To this:
Code
<br />   while (list($key,$value) = each($config)) {<br />      if (!ereg("-$key-",$knownkeys)) {<br />          if ( is_array($config[$key]) ) {<br />              $printvalue = "array(";<br />              while (list($akey,$aval) = each($config[$key])) {<br />                  $printvalue .= "'$akey' => \"$aval\",\n";<br />              }<br />              $printvalue .= ")";<br />          } else {<br />              $printvalue = "'$config[$key]'";<br />          }<br />         $extras .= "\$config['$key'] =	$printvalue;\n";<br />      }<br />   }<br />

Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
You might try something like:

Code
$config['groupcolor'] = "array(<br />    '5' => 'Normal',<br />    '6' => '#FF6600',<br />    )";


and then do an eval. But the config editor might get confused by the nested quotes.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
I'll give that a shot.

Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Thanks, that did the trick, without having to hack admin/editconfig.php.

Here's how I did, I put this in the config file:
Code
$config['groupcolor'] =	'array("5" => "Normal",<br />"6" => "#FF6600",<br />)';<br />

And did this in the script to get the array:
Code
   eval("\$groupcolor = {$config['groupcolor']};");<br />


That works, but if one quotation mark is wrong it can break the editconfig page.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,079
Joined: March 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)