Jump to content

Template error when I use variables in lang tags


goldmorphin

Recommended Posts

Posted

Hello! I have weird problem with this code:

{{foreach $user['general'] as $key => $array}}

<h3 class="ipsType_sectionHead ipsSpacer_bottom ipsSpacer_half">{lang="api_{$key}"}</h3>

<table class="ipsTable">
  <tr>
    <th>Name</th>
    <th>Description</th>
  </tr>
  {{foreach $array as $param => $value}}
  <tr>
    <td>
      <code>{$param}</code>
    </td>
    <td>{$value}</td>
  </tr>
  {{endforeach}}
</table>
{{endforeach}}

when I'm try to use {lang="api_{$val}"} - its working for <h3> element and I see translated text, but next foreach doesn't work and all rows is empty.

But when I put something like:

<h3 class="ipsType_sectionHead ipsSpacer_bottom ipsSpacer_half">{$val}</h3>

all code in template is working fine. Why it's happening? What I'm doing wrong?

Posted

For testing, try

{{$key = "api_" . $langKey;}}
{lang="$key"}

Without firing up a test instance it's hard to confirm, but interpolating the { and } inside the plugin tag may be confusing the template parser.

Posted

I'd first check your data structure you're looping through. I'm doing something almost exactly the same, and it works without issue. 

{{foreach $member->bf4 as $plat => $data}}
				<li class="ipsMenu_item">
					<a href="{url='...' csrf='true'}">
						<span>{lang="bf4_{$plat}"}: {datetime="$data->last_update" short="TRUE"}</span>
					</a>
				</li>
				{{endforeach}}

 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...