PDA

View Full Version : Updating Mod to v4... while not iterating?


zanthor
12-28-2009, 11:15 PM
So I've gone through and fixed the template, and I've gone through the PHP and something isn't right...

Before:
while ($player = $db->fetch_array($res))
{
// code excluded

eval('$rosterbits .= "' . fetch_template('gwr_roster_bit') . '";');
}

With this code it dumped out the full roster of my guild.

After:
while ($player = $db->fetch_array($res))
{
// Code Excluded

$templater = vB_Template::create('gwr_roster_bit');
$templater->register_page_templates();
$templater->register('player', $player);
$templater->register('gwr_phrase', $gwr_phrase);
$templater->register('guild', $guild);
$templater->register('armory', $armory);
print_output($templater->render());
}

With this code it only dumps the first character.

I'm sure I'm doing something wrong, but I'm not sure what.

consolegaming
12-29-2009, 12:38 AM
What about trying the render line outside of the loop and changing the first line of your while loop to:

$templater .= vB_Template::create('gwr_roster_bit');

I'm not sure if that wold work exactly but I think that's closer to what you need. I think you just need the render line to be called once and that you jsut append to the $templater variable each loop.

i.e.

while ($player = $db->fetch_array($res))
{
// Code Excluded

$templater .= vB_Template::create('gwr_roster_bit');
$templater->register_page_templates();
$templater->register('player', $player);
$templater->register('gwr_phrase', $gwr_phrase);
$templater->register('guild', $guild);
$templater->register('armory', $armory);
}
print_output($templater->render());


Like I said though I'm not sure if that's exactly what you need or if you'll need to still register those variables in each loop. But it should at least be a step in the right direction.

zanthor
12-29-2009, 12:50 AM
This was the direction I took, and it's working quite well...

I'm in the middle of totally rewriting the template now in a consolidated template, but HTML is actually my weakness!

Anyhow in the php I setup a player_data array and added the players to it, registered that, etc... and called the render once.

consolegaming
12-29-2009, 12:54 AM
Sounds cool, good luck with it. Hope it goes well.

BTW if you plan to release this updated mod once your done I'd check with the original coder of the mod (assuming you aren't the originator as you have no mods posted) before doing so.

zanthor
12-29-2009, 02:12 AM
Sounds cool, good luck with it. Hope it goes well.

BTW if you plan to release this updated mod once your done I'd check with the original coder of the mod (assuming you aren't the originator as you have no mods posted) before doing so.

Current plans are to e-mail the code back to him once I'm done... of course I like the idea better where he beats me to the punch and releases before me!