Get current color palette from color.module in Garland

stoeckler - January 12, 2008 - 02:26

Hey guys and gals & thanks for reading this,

I have been searching for a solution everywhere; this site of course, as well as a google search with site:drupal.org. But found nothing promising. My problem is:

I would like to be able to get the 5 current colors 'base', 'link', 'top', 'bottom', 'text' (as they can be modified by color.module) to be usable in my template.php. The function color_get_palette seems to be the appropriate attempt, at least as far as i can tell. Calling it (or copy-pasting and changing function name) does, however, not work but instead provides the following error messages:

* warning: array_keys() [function.array-keys]: The first argument should be an array in /var/www/vhosts//httpdocs/themes//page.tpl.php on line 95.
* warning: array_shift() [function.array-shift]: The argument should be an array in /var/www/vhosts//httpdocs/themes//page.tpl.php on line 96.

Could you please tell me (if you know or can guess): Am I on the right track? What did I not consider? Is there another way to do this?

Thank you very much!

Jan

Passing in the name of the

dvessel - January 12, 2008 - 04:10

Passing in the name of the theme will return the color scheme assuming you setup color.module correctly for it.

I do that, doesn't work though

stoeckler - January 12, 2008 - 11:39

I forgot to include that in my initial post. I do pass the name of the theme as parameter of the function.

For some reason, the lines
  $keys = array_keys($info['schemes']);
and
foreach (explode(',', array_shift($keys)) as $k => $scheme) { ... }
in the function color_get_palette seem to be the problem, according to the error messages.

For some reason, $info does not seem to be the correct array (or an array at all), which means the line which should provide for that,   $info = color_get_info($theme); might not work correctly. I tried $info = color_get_info($theme) with my theme name and it does not work, does not return anything to $info.

 
 

Drupal is a registered trademark of Dries Buytaert.