Accessing specific custom fields, non-sequentially

joelion

Joined: 2004-11-04
Posts: 19
Posted: Sat, 2005-12-17 17:04

So I've gone through the whole
foreach from=$block.customfield.LoadCustomFields.fields key=field item=value
to get custom fields sequentially, but how do I gain non-sequential access to specific fields. I've tried all the array tricks I know but I can't figure out how the smarty array works.

Alternatively, do the TPL files allow you to define local variables to store temporary information.

Finally, is there a way to get the numerical index of the current array value, or is it a fully associative array where the fields can only be accessed by their keys

What i'm getting at is this (pseudocode):

{foreach customfields}
  {if $field==xxx}
    <tr>
  {/if}
      <td>{$value|markup}</td>
  {if $field==yyy}
      <td><a href="zzz.php?n={$theme.item.title}&m={$customfieldvaluex}&p={$customfieldvaluex+1}m={$customfieldvaluex+2}">Order</a></td>
    </tr>
  {/if}
{/foreach}
 
joelion

Joined: 2004-11-04
Posts: 19
Posted: Mon, 2005-12-19 11:03

surely this can be done. There has to be ways to access other indici in the CustomFields array, right?

 
joelion

Joined: 2004-11-04
Posts: 19
Posted: Tue, 2005-12-20 08:32

btw, if anybody cares - Termitenshort worked with me to solve the problem.
Turns out the spaces in the CustomField field names were a problem. Even though the custom fields work fine with spaces, you can't access each field directly if they do have spaces. So if you remove the spaces, you can get to each field with simply

$block.customfield.LoadCustomFields.fields.field1name
$block.customfield.LoadCustomFields.fields.field2name
 
willie512

Joined: 2006-05-06
Posts: 14
Posted: Tue, 2006-05-09 02:04

Valuable info!