Hi
I'm using display suite and I'm getting this error message.
The line highted in bold

Many Thanks for your help

Notice: Undefined index: #formatter in commons_origins_preprocess_field() (line 1101 of /var/www/mysite/profiles/commons/themes/commons/commons_origins/template.php).

foreach ($links as $key => $link) {
if (!isset($link['#access']) || $link['#access'] !== FALSE) {
$class = array($key);

// Add first, last and active classes to the list of links to help out themers.
if ($i == 1) {
$class[] = 'first';
}
if ($i == $num_links) {
$class[] = 'last';
}

if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language_url->language)) {
$class[] = 'active';
}
$output .= '

  • $class)) . '>';

    if (isset($link['href'])) {
    // Pass in $link as $options, they share the same keys.
    $output .= l($link['title'], $link['href'], $link);
    }
    elseif (!empty($link['title'])) {
    // Some links are actually not links, but we wrap these in for adding title and class attributes.
    if (empty($link['html'])) {
    $link['title'] = check_plain($link['title']);
    }
    $span_attributes = '';
    if (isset($link['attributes'])) {
    $span_attributes = drupal_attributes($link['attributes']);
    }
    $output .= '' . $link['title'] . '';
    }

    $i++;
    $output .= "

  • \n";
    }
    }

    $output .= '

    ';
    }

    return $output;
    }

    Comments

    charlie charles’s picture

    Title: Display Suite » Notice: Undefined index: #formatter in commons_origins_preprocess_field()
    charlie charles’s picture

    Issue summary: View changes
    Antonio01’s picture

    Hi Charlie Charles,

    I had this same problem to

    In this function in template.php I added this line. "if (isset($variables['element']['#formatter'])){ .... }"

    The problem is i don't know to create a patch and really no have any idea of what is a "Formatter". Ezra on the irc told me i need to put an isset and they will investigate.

    /**
     * Implements hook_preprocess_field().
     */
    function commons_origins_preprocess_field(&$variables, $hook) {
     
    if (isset($variables['element']['#formatter'])){
     // Style the trusted contact link like a button.
      if ($variables['element']['#formatter'] == 'trusted_contact') {
        foreach ($variables['items'] as &$item) {
          if (isset($item['#options'])) {
            $item['#options']['attributes']['class'][] = 'action-item-small';
          }
          if (isset($item['#href']) && strpos($item['#href'], 'messages')) {
            $item['#options']['attributes']['class'][] = 'message-contact';
          }
          elseif (isset($item['#href'])) {
            $item['#options']['attributes']['class'][] = 'trusted-status-request';
          }
        }
      }
     }
    }
    
    

    I hope it could help, i will try to create the patch file ...

    Antonio

    freakalis’s picture

    Here is a patch that solves this by adding an isset first.

    japerry’s picture

    Version: 7.x-3.8 » 7.x-3.x-dev
    Status: Active » Needs review

    Ahh that makes sense with display suite. Looks good to me, I don't have DS to test against, but if it doesn't regress into commons stock (which it shouldn't.. its just an additional check), then we can commit.

    japerry’s picture

    Priority: Normal » Major

    • Commit 215bb30 on 7.x-3.x by japerry:
      Issue #2187245 by Antonio01, Freakalis, Charlie Charles: Suppress...
    japerry’s picture

    Status: Needs review » Fixed

    Tested on our stock version of commons, no regressions there. Fixed!

    Status: Fixed » Closed (fixed)

    Automatically closed - issue fixed for 2 weeks with no activity.