Assembling variables in the template

From: Date: Wed, 19 Feb 2003 17:35:07 +0000
Subject: Assembling variables in the template
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7910@lists.php.net to get a copy of this message
Hi all, I have quite a bit of {section} statements in my template. Everything goes smoothly untill: (@see template snippet at the end of this message) {* POINT 1 *}. Here I am trying to generate $key variable. Looks like value attrubute of the assign custom function can be a string, not something composed of other template variables. What I get here is '---' as opposed to what I expect ex.: '1-4-2-3'. Is there any other way to do that? {* POINT 2 *} Here I am trying to retrieve values from the $test_results array, which has the following structure: $test_results = array( 'sess_23' => array(
    '1-4-2-1' => array( // this is a key from POINT 1
      'avg_rate'     => 999.99,
      'elapsed_time' => 999,
      'cpu_load'     => 99,
    ),
    '1-4-2-2' => array(
      'avg_rate'     => 888.88,
      'elapsed_time' => 888,
      'cpu_load'     => 88,
    ),
    ...
), 'sess_48' => array(
    ...
), ... ); Again Smarty doesn't like: {$test_results.$sessions_sorted[sess].$key.$res_showfields[rsf]} Is there any work around? Or maybe I am doing somethin wrong? Any help is appreciated! ;o) - dmitri {* Test results rows *} {section name=cg loop=$client_groups} {section name=rs loop=$reqsizes}
    {section name=tg loop=$targets}
      {section name=rn loop=$runs}
        <tr bgcolor="{#commonRowsColor#}">
          <td>{$client_groups[cg]}</td>
          <td>{math equation="r * t" r=$reqsizes[rs]
                                     t=$targets[tg]}</td>
          <td>{$targets[tg]}</td>
          <td>{$runs[rn]}</td>
          {* POINT 1 *}
          {assign var=key value=
             "$client_groups[cg]-$reqsizes[rs]-$targets[tg]-$runs[rn]"}
          {* show selected result fields for each session *}
          {section name=sess loop=$sessions_sorted}
            {section name=rsf loop=$res_showfields}
              <td>
        {* POINT 2 *}
        {$test_results.$sessions_sorted[sess].$key.$res_showfields[rsf]}
              </td>
            {/section}
          {/section}
          {* end of show selected result fields for each session *}
        </tr>
      {/section}
    {/section}
{/section} {/section} {* End test results rows *}

« previous php.smarty.general (#7910) next »