Answers.Body: <p>Here's an attempt to address this with a token that can be used with Fuzion's <a href="https://github.com/eileenmcnaughton/nz.co.fuzion.civitoken" rel="nofollow">CiviToken</a> extension. With that extension installed, this token file can be added to a <code>tokens</code> directory in your custom PHP folder to provide a "Latest Contrib Soft Credit Name" token. (It checks the latest contribution and if there is a soft credit adds the name(s) in this token). The caveat being that it only checks the latest contribution and won't work for previous contributions.</p>
  
  <p><a href="https://github.com/laryn/nz.co.fuzion.civitoken/blob/master/tokens/latestcontribs.inc" rel="nofollow">https://github.com/laryn/nz.co.fuzion.civitoken/blob/master/tokens/latestcontribs.inc</a></p>
  
  <p>File: <strong>tokens/latestcontribs.inc</strong></p>
  
  <pre><code>&lt;?php
  
  function latestcontribs_civitoken_declare($token){
    return array(
      $token . '.softcredit_name' =&gt; 'Latest Contrib Soft Credit Name',
    );
  }
  
  
  function latestcontribs_civitoken_get($cid, &amp;$value, $context){
    $params = array(
      'sequential' =&gt; 1,
      'contact_id' =&gt; $cid,
      'options' =&gt; array('sort' =&gt; "receive_date DESC", 'limit' =&gt; 1),
    );
    $softcredit_formatted = "";
  
    $softcredit_name = civicrm_api3('Contribution', 'getsingle', $params);
  
    if (isset($softcredit_name['soft_credit'])) {
      $connector = "";
      $i = 0;
      $total = count($softcredit_name['soft_credit']);
      foreach($softcredit_name['soft_credit'] as $softcredit) {
        $i++;
        $softcredit_formatted .= $connector.$softcredit['contact_name'];
        if ($i == ($total-1) ) {
          $connector = " and ";
        } else {
          $connector = ", ";
        }
      }
    }
    $value['latestcontribs.softcredit_name'] = $softcredit_formatted;
    return $value;
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-09-11T16:41:03.990Z
Answers.Text: For future readers - this token is now built into CiviToken, so you can just install that.
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-25T19:55:30.637Z
Answers.LastActivityDate: 2016-01-25T19:55:30.637Z
Answers.UserDisplayName: Laryn
Body: <p>I have hunted and not found anything so I am assuming that this does not exist -- but thought I'd ask just in case. I'd like to be able to reference the soft credit / honoree information in Thank You letters but can't find this as a token.</p>
  
  <p>I guess it's tricky to do this as a token since it relates to a specific contribution and not the contact in general. What is the best way to try to do this?</p>
  
Tags: <civicontribute><tokens><message-templates><honoree><soft-credit>
Title: Soft credit / honoree info in a token for Thank You letters?
ThreadText: # Soft credit / honoree info in a token for Thank You letters?
  
  (Asked by: username_0 on 2015-12-17)
  
  I have hunted and not found anything so I am assuming that this does not exist -- but thought I'd ask just in case. I'd like to be able to reference the soft credit / honoree information in Thank You letters but can't find this as a token.
  
  I guess it's tricky to do this as a token since it relates to a specific contribution and not the contact in general. What is the best way to try to do this?
  
  **Tags:** civicontribute, tokens, message-templates, honoree, soft-credit
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-01-25. Score: 4 | Accepted answer
  
  Here's an attempt to address this with a token that can be used with Fuzion's CiviToken extension. With that extension installed, this token file can be added to a tokens directory in your custom PHP folder to provide a "Latest Contrib Soft Credit Name" token. (It checks the latest contribution and if there is a soft credit adds the name(s) in this token). The caveat being that it only checks the latest contribution and won't work for previous contributions.
  https://github.com/laryn/nz.co.fuzion.civitoken/blob/master/tokens/latestcontribs.inc
  File: tokens/latestcontribs.inc
   'Latest Contrib Soft Credit Name',
    );
  }
  
  
  function latestcontribs_civitoken_get($cid, &$value, $context){
    $params = array(
      'sequential' => 1,
      'contact_id' => $cid,
      'options' => array('sort' => "receive_date DESC", 'limit' => 1),
    );
    $softcredit_formatted = "";
  
    $softcredit_name = civicrm_api3('Contribution', 'getsingle', $params);
  
    if (isset($softcredit_name['soft_credit'])) {
      $connector = "";
      $i = 0;
      $total = count($softcredit_name['soft_credit']);
      foreach($softcredit_name['soft_credit'] as $softcredit) {
        $i++;
        $softcredit_formatted .= $connector.$softcredit['contact_name'];
        if ($i == ($total-1) ) {
          $connector = " and ";
        } else {
          $connector = ", ";
        }
      }
    }
    $value['latestcontribs.softcredit_name'] = $softcredit_formatted;
    return $value;
  }
  
  > **Comments:**
  > **username_1**: For future readers - this token is now built into CiviToken, so you can just install that.  
  
  ---
  
  