drupal-tweme icon indicating copy to clipboard operation
drupal-tweme copied to clipboard

Fatal error: [] operator not supported for strings

Open anton-staroverov opened this issue 10 years ago • 2 comments

Fatal error: [] operator not supported for strings in /tweme/template.php on line 111

anton-staroverov avatar Jul 26 '15 16:07 anton-staroverov

Hi Tony,

I left a comment in the commit too and I believe I've just fixed this issue.

The problem happens when using Panels IPE. If you look into file panels/panels_ipe/panels_ipe.module at lines 139 and 204, you’ll see that only line 139 adds a class as a string instead of an array.

So, I changed the code so that it first checks whether $vars[‘attributes’][‘class’] is an array. If it holds a string, then turn it into an array, add the existing class and then continue with adding the ‘list-unstyled’ class.

I ran into this issue on my own website (condurachi.ro) and I thought I’d give a helping hand. I really like your theme.

Regards, Andrei

acondura avatar Aug 26 '15 16:08 acondura

I tried syncing my commit to your repo but it looks like I don't have the right permissions. Here's the code change that I did to solve the issue:

function tweme_preprocess_links(&$vars) {

Check if the class value is not an array

if(!is_array($vars['attributes']['class'])) { # Hold the existing value in variable $temp_value = $vars['attributes']['class']; # Transform the class to an array $vars['attributes']['class'] = array(); # Add the existing value to the class array $vars['attributes']['class'][] = $temp_value; } $vars['attributes']['class'][] = 'list-unstyled'; }

acondura avatar Aug 26 '15 17:08 acondura