The documentation is very clear on how to use a code block any number of times, and the technique works for any large number.
But it's not clear on the correct usage when the number can only range from 0 to 1.
The two player game is extremely unique, with a lot of HTML for the two player game. I need to show that HTML once in a 2 player game, or zero times in a 3-6 player game.
.tpl
.view.php
So it all runs... fine. It does exactly what I intended it to do. But it feels... improper. Like anyone reading through my code would be left scratching their head saying "what is... oh I see, but why didn't you do it the NORMAL way?"
Is there a normal way? Or was that it?
The BGA documentation is literally the only thing I know about .tpl files. I know absolutely nothing about them outside of what's written there.
Thanks in advance
Edit:
Attempt 2, not sure if the code just got more proper or less proper:
.view.php
But it's not clear on the correct usage when the number can only range from 0 to 1.
The two player game is extremely unique, with a lot of HTML for the two player game. I need to show that HTML once in a 2 player game, or zero times in a 3-6 player game.
.tpl
Code: Select all
<!-- BEGIN game2p -->
//20 lines of HTML, including a nested code block with another code block inside that
<!-- END game2p -->Code: Select all
if($players_nbr == 2){
$this->page->begin_block( "name_name", "innerBlock" );
$this->page->begin_block( "name_name", "outerBlock" );
$this->page->begin_block( "name_name", "game2p" );
for($i = 1; $i <=4; $i++){
$this->page->reset_subblocks( 'innerBlock' );
for( $j=1; $j<=4; $j++ ) {
$this->page->insert_block(
"innerBlock", array(
//args
)
);
}
$this->page->insert_block(
"outerBlock", array(
//args
)
);
}
$this->page->insert_block(
"game2p", array()
);
} else {
$this->page->begin_block( "name_name", "game2p" );
}Is there a normal way? Or was that it?
The BGA documentation is literally the only thing I know about .tpl files. I know absolutely nothing about them outside of what's written there.
Thanks in advance
Edit:
Attempt 2, not sure if the code just got more proper or less proper:
.view.php
Code: Select all
$this->page->begin_block( "name_name", "innerBlock" );
$this->page->begin_block( "name_name", "outerBlock" );
$this->page->begin_block( "name_name", "game2p" );
if($players_nbr == 2){
for($i = 1; $i <=4; $i++){
$this->page->reset_subblocks( 'innerBlock' );
for( $j=1; $j<=4; $j++ ) {
$this->page->insert_block(
"innerBlock", array(
//args
)
);
}
$this->page->insert_block(
"outerBlock", array(
//args
)
);
}
$this->page->insert_block(
"game2p", array()
);
} else {
//3+ player code
}