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
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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.