TheMagician Posted April 19, 2009 Share Posted April 19, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/154760-solved-phpbb2-template-engine-problem/ Share on other sites More sharing options...
TheMagician Posted April 19, 2009 Author Share Posted April 19, 2009 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> Quote Link to comment https://forums.phpfreaks.com/topic/154760-solved-phpbb2-template-engine-problem/#findComment-813904 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.