It has been a long time.
But I'll cut right to the point!
I am assigning an array in a block of vars and in that array I have another one array. So far so good everything looks to work "fine".
Except that I get the message of the subject
context.php on line 148: Invalid argument supplied for foreach()]
.Here is the php part of the problem:
Code: Select all
$sql = 'SELECT * from ' . $this->utl_table;
$list_rules = $db->sql_query($sql);
if($list_rules)
{
while ($rule = $db->sql_fetchrow($list_rules))
{
$forums = json_decode($rule['utl_rule_forum_ids'], true);
$sql = 'SELECT forum_name FROM ' . FORUMS_TABLE . ' WHERE ' . $db->sql_in_set('forum_id', $forums);
$res = $db->sql_query($sql);
$forum_names = $db->sql_fetchrowset($res);
foreach ($forum_names as $name)
{
$clean[] = $name['forum_name'];
}
$rule = array_merge($rule, array('utl_forum_names' => $clean));
unset($clean);
$db->sql_freeresult($res);
$template->assign_block_vars('andreask_utl_rules', $rule);
}
$db->sql_freeresult($list_rules);
}
Code: Select all
<thead>
<tr>
<th>{{ lang('NAME') }}</th>
<th>{{ lang('DAYS') }}</th>
<th>{{ lang('DAYS_OPTION') }}</th>
<th>{{ lang('POSTS') }}</th>
<th>{{ lang('POSTS_OPTION') }}</th>
<th>{{ lang('MAX_POSTS') }}</th>
<th>{{ lang('MAX_POSTS_OPTION') }}</th>
<th>{{ lang('FORUMS') }}</th>
<th>{{ lang('DATE') }}</th>
<th>{{ lang('ACTIVE') }}</th>
</tr>
</thead>
<tbody>
{% for rule in andreask_utl_rules %}
<tr>
<td><a href="{{ rule.S_EDIT_URL }}">{{ rule.utl_rule_name }}</a></td>
<td>{{ rule.utl_rule_amount_of_days }}</td>
<td>{{ rule.utl_rule_amount_of_days_opt }}</td>
<td>{{ rule.utl_rule_amount_of_posts }}</td>
<td>{{ rule.utl_rule_amount_of_posts_opt }}</td>
<td>{{ rule.utl_rule_max_posts }}</td>
<td>{{ rule.utl_rule_max_posts_opt }}</td>
<td>{% for forum in rule.utl_forum_names %}{{ forum }}</br>{% endfor %}</td>
<td>{{ rule.utl_rule_created_date }}</td>
<td>{{ rule.utl_rule_active }}</td>
</tr>
{% else %}
<tr>
<td colspan="6" style="text-align: center;">{{ lang('ANDREASK_NOTHING_YET')}}</td>
</tr>
{% endfor %}
</tbody>
</table>
What am I doing wrong?