Error Undefined index

Game development with Board Game Arena Studio
Post Reply
Cowseye
Posts: 26
Joined: 11 August 2013, 17:33

Error Undefined index

Post by Cowseye »

Hi all, I am following the tutorial to create elements on the board game I am developing. I am working on tpl, css and view file at the moment. I met some error which I do not understand what causes it.

I am loading my game board after I added a tile element in my css:

.tile {
width: 60px;
height: 60px;
position: absolute;
background-color: red;
}

I followed by editing the tpl file:
<div id="board">
<!-- BEGIN tile -->
<div id="tile_{X}_{Y}" class="tile" style="left: {LEFT}px; top: {TOP}px;"></div>
<!-- END tile -->
</div>

And I attempt to add a tile element on the board in the view file:

function build_page( $viewArgs )
{
// Get players & players number
$players = $this->game->loadPlayersBasicInfos();
$players_nbr = count( $players );

/*********** Place your code below: ************/

//$this->page->begin_block( "greatwesterntrailgwt_greatwesterntrailgwt", "tile" );


$this->page->insert_block( "tile", array('X' => 381,'Y' => 168,'LEFT' => 381,'TOP' => 168) );
.
.
.
.
}

Upon loading my game board, I got the following error on the top of the page:

Notice: Undefined index: tile in /var/tournoi/release/tournoi-151226-1240-gs/www/include/APP_Template.inc.php on line 140

I notice this has to do with my tile element, but I do not understand the cause of error.

Please help a noob. Thank you.
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Error Undefined index

Post by Victoria_La »

why did you comment out begin_block? It has to be there too
Cowseye
Posts: 26
Joined: 11 August 2013, 17:33

Re: Error Undefined index

Post by Cowseye »

When I didn't, the page halt with a blank page an error that says could not load block or something like that. It could not even procerd to load any UI.
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Error Undefined index

Post by Victoria_La »

I can load your game now, did you fix it?
You have to have both calls to deal with templates. What exactly error did you get? If it says its missing block the block
named tile is not there, make sure you .tpl file actually synced to server.

There are other options though, you can generate same html from javascript for example.
Cowseye
Posts: 26
Joined: 11 August 2013, 17:33

Re: Error Undefined index

Post by Cowseye »

I do not know how I got it to work. I retry the following day and it works unknowingly.

However, I attempt to add another element into the template and wanted to do another begin block. The same error message appears again.

View.php:

$this->page->begin_block( "greatwesterntrailgwt_greatwesterntrailgwt", "tile" );
$this->page->begin_block( "greatwesterntrailgwt_greatwesterntrailgwt", "smalltile" );

TPL file:
<div id="board">
<!-- BEGIN tile -->
<div id="tile_{NAME}" class="tile" style="left: {LEFT}px; top: {TOP}px;"></div>
<div id="smalltile_{NAME}" class="smalltile" style="left: {LEFT}px; top: {TOP}px;"></div>
<!-- END tile -->
</div>

CSS file:

.tile {
width: 60px;
height: 60px;
position: absolute;
background-color: red;
}

.smalltile {
width: 30px;
height: 37px;
position: absolute;
background-color: blue;
}


Error on page load:

Template Error: set_block: unable to set block smalltile.
Halted.

Hope to get some enlightenment on how to work with multiple blocks. I intend to create this as placeholders for future tiles to be inserted on the board.
Cowseye
Posts: 26
Joined: 11 August 2013, 17:33

Re: Error Undefined index

Post by Cowseye »

Nvm, problem solved.
Little did I know that the comment lines in the TPL files for begin and end was use to define the blocks....

There are much reading to be done before I could get something to work for my game. LOL
Fabian Viking
Posts: 4
Joined: 09 July 2021, 07:22

Re: Error Undefined index

Post by Fabian Viking »

Cowseye wrote: 08 January 2017, 09:40 The comment lines in the TPL files for begin and end was use to define the blocks
This solved my issue too
Post Reply

Return to “Developers”