3 replies [Last post]
kiwi_steve's picture
Offline
Joined: 01/14/2008
Juice: 131
Was this information Helpful?

Hi all... its been a while since I was on the forums here, but I have run into a small problem that is driving me nuts (mainly due to my inability to speak fluent PHP).

I'm working on a new site layout, based on Sky (which I have used before - but its come a long way since then). It was all going swimmingly until I decided to add an attribute for a product. Now I get the following error when viewing that product:
recoverable fatal error: Object of class stdClass could not be converted to string in /var/www/nasebygold/www/sites/all/themes/sky/functions/theme-custom.inc on line 25.

The code it refers to is as follows (snipped from the theme-custom.inc file):

/**
* Create a string of attributes form a provided array.
* Credit: Studio ">http://drupal.org/project/studio
*
* @param $attributes
* @return string
*/
function sky_render_attributes($attributes) {
  if ($attributes) {
    $items = array();
    foreach ($attributes as $attribute => $data) {
      if (is_array($data)) {
        $data = implode(' ', $data);
      }
      $items[] = $attribute .'="'. $data .'"';
    }
    $output = ' '. str_replace('_', '-', implode(' ', $items));
  }
  return $output;
}

Can anyone see something obvious, or suggest somewhere to look? I'd appreciate any pointers. I did try commenting out this function, but it threw up multiple other errors from the core includes directory so I guess this is tied in and is needed.

Anyway, I'll look forward to any help anyone can give Smiling

Cheers

Steve

--- There are no personal problems that can not be overcome with the liberal application of high explosives ---

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
kiwi_steve wrote: Hi all...
kiwi_steve wrote:

Hi all... its been a while since I was on the forums here, but I have run into a small problem that is driving me nuts (mainly due to my inability to speak fluent PHP).

I'm working on a new site layout, based on Sky (which I have used before - but its come a long way since then). It was all going swimmingly until I decided to add an attribute for a product. Now I get the following error when viewing that product:
recoverable fatal error: Object of class stdClass could not be converted to string in /var/www/nasebygold/www/sites/all/themes/sky/functions/theme-custom.inc on line 25.

The code it refers to is as follows (snipped from the theme-custom.inc file):

/**
* Create a string of attributes form a provided array.
* Credit: Studio ">http://drupal.org/project/studio
*
* @param $attributes
* @return string
*/
function sky_render_attributes($attributes) {
  if ($attributes) {
    $items = array();
    foreach ($attributes as $attribute => $data) {
      if (is_array($data)) {
        $data = implode(' ', $data);
      }
      $items[] = $attribute .'="'. $data .'"';
    }
    $output = ' '. str_replace('_', '-', implode(' ', $items));
  }
  return $output;
}

Can anyone see something obvious, or suggest somewhere to look? I'd appreciate any pointers. I did try commenting out this function, but it threw up multiple other errors from the core includes directory so I guess this is tied in and is needed.

Anyway, I'll look forward to any help anyone can give Smiling

Cheers

Steve

Yeah, that's a problem with the Studio/Sky theme that I thought had been addressed a long time ago. I don't use those themes myself so I haven't followed it closely. There were a number of issues posted on drupal.org. The problem is that the *theme* adds a variable called "attributes" to every node object, which is a problem because Ubercart products already have a variable called attributes, so the theme overwrites Ubercart. You can read one discussion here: http://drupal.org/node/478952

<tr>.
kiwi_steve's picture
Offline
Joined: 01/14/2008
Juice: 131
Re: kiwi_steve wrote: Hi all...

Thanks TR... appreciate the link. I'll look into it....

Steve

--- There are no personal problems that can not be overcome with the liberal application of high explosives ---

kiwi_steve's picture
Offline
Joined: 01/14/2008
Juice: 131
Re: Re: kiwi_steve wrote: Hi all...

Dumped the theme and left them a "fix it" note Smiling

--- There are no personal problems that can not be overcome with the liberal application of high explosives ---