Please see the patch below.

My use-case / intention for this patch:

Using a custom field as link title is featured by setting the link title to static and use tokens. If there is no result for these tokens (due to empty fields), token_replace() currently ignores (and spits out) the tokens.

The patch instructs token_replace() to clear tokens for which no value can be generated. So, if custom fields are empty and result to an empty link title, the Link module will again be able to use the URL as default value.

I've added the clear-flag for link title and title attribute only, because for the URL it is important the user is aware of some missing values and should see the raw tokens.

CommentFileSizeAuthor
remove-tokens-without-value.patch1.19 KBAnonymous (not verified)

Comments

chris matthews’s picture

Issue summary: View changes
Status: Needs review » Needs work
Issue tags: +Needs reroll

The 17 Sep 2012 patch to link.module does not apply to the latest link 7.x-1.x-dev and if still applicable needs a reroll.

Checking patch link.module...
error: while searching for:
    else {
      $entity_loaded = $entity;
    }
    $title = filter_xss(token_replace($title, array($entity_token_type => $entity_loaded)),
                        array('b', 'br', 'code', 'em', 'i', 'img', 'span', 'strong', 'sub', 'sup', 'tt', 'u'));
    $item['html'] = TRUE;
  }

error: patch failed: link.module:514
error: link.module: patch does not apply