Jump to content

[SOLVED] PhpBB2 Template Engine Problem


TheMagician

Recommended Posts

I know this should go to phpBB MOD forums, but the phpBB2 section is completely locked down so I can't ask it there.

 

So basically, I have a problem with having a loop inside a switch

 

<!-- template.tpl -->
<!-- BEGIN switch_show_team_selector -->
<select name="team">
<!-- BEGIN loop_teams -->
<option value="{loop_teams.TEAM_ID}">{loop_teams.TEAM_NAME} ({loop_teams.TEAM_PARTNER})</option>
<!-- END loop_teams -->
<!-- END switch_show_team_selector -->
</select>

 

<?php

// set template file
$template->set_filenames(array(
'team_selector' => 'template.tpl')
);

i
// IF found one or more teams: show the select element
$template->assign_block_vars('switch_select_team', array());

// WHILE: output all found teams within option elements inside the select element
$template->assign_block_vars('switch_select_team.loop_teams', array(
'TEAM_ID' => $row['team_id'],
'TEAM_NAME' => $row['team_name']),
'TEAM_PARTNER' => $row['team_partner'])
);

// render team selector
$template->pparse('team_selector');

// clean data
$template->destroy();

?>

 

This code almost works, except that the values aren't outputted, but it still outputs as many option elements as there are found teams.

 

If I change 'switch_select_team.teams' to just 'teams' then no option elements are outputted at all.

 

I've tried everything I can think of, can anyone who's familiar with the engine help?

Link to comment
https://forums.phpfreaks.com/topic/154760-solved-phpbb2-template-engine-problem/
Share on other sites

Apparently I had to change this line:

 

<option value="{loop_teams.TEAM_ID}">{loop_teams.TEAM_NAME} ({loop_teams.TEAM_PARTNER})</option>

 

To:

 

<option value="{switch_show_team_selector.loop_teams.TEAM_ID}">{switch_show_team_selector.loop_teams.TEAM_NAME} ({switch_show_team_selector.loop_teams.TEAM_PARTNER})</option>

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.