|
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: $config['groupcolor'] = array(<br /> "5" => "Normal",<br /> "6" => "#FF6600",<br /> );<br /> Or is this something I should report as a bug?
|
|
|
|
Joined: Apr 2002
Posts: 1,768
Addict
|
Addict
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.
|
|
|
|
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: <br /> while (list($key,$value) = each($config)) {<br /> if (!ereg("-$key-",$knownkeys)) {<br /> $extras .= "\$config['$key'] = '$config[$key]';\n";<br /> }<br /> }<br /> To this: <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
Joined: Apr 2002
Posts: 1,768 |
You might try something like: $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 |
|
|
|
|
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: $config['groupcolor'] = 'array("5" => "Normal",<br />"6" => "#FF6600",<br />)';<br /> And did this in the script to get the array: eval("\$groupcolor = {$config['groupcolor']};");<br /> That works, but if one quotation mark is wrong it can break the editconfig page.
|
|
|
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.
|
|
Posts: 808
Joined: July 2001
|
|
Forums63
Topics37,575
Posts293,931
Members13,823
|
Most Online6,139 Sep 21st, 2024
|
|
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
|
|
|
|