TonyCisseroni Posted January 26, 2020 Share Posted January 26, 2020 (edited) I've started building my own mod for GL2, it's a basic dice game. The game works and shows the dice totals in the error / success message. And I'm storing the results of each dice in session variables, which I also see is working. array(2) { ["userID"]=> string(1) "1" ["DICE_GAME"]=> array(2) { ["diceone"]=> int(2) ["dicetwo"]=> int(4) } } I'm looking at the BlackJack game MOD code as an example and I see they are reading session variables in the TPL file like this {card} {suite} etc. I tried this same method using {diceone} and {dicetwo} in my TPL file but it's not showing my result. Is there any documentation on the templating or does someone know what I'm missing here? <div class="dice">dice one: {diceone} dice two: {dicetwo}</div> Edited January 26, 2020 by TonyCisseroni Quote Link to comment Share on other sites More sharing options...
KyleMassacre Posted January 26, 2020 Share Posted January 26, 2020 What does your method look like? Preferably where you are “building” your element to the page 1 Quote Link to comment Share on other sites More sharing options...
TonyCisseroni Posted January 26, 2020 Author Share Posted January 26, 2020 44 minutes ago, KyleMassacre said: What does your method look like? Preferably where you are “building” your element to the page I see, building the element appears to be the part I was missing. I will look into that a little further. 😊 Quote Link to comment Share on other sites More sharing options...
Dave Posted January 26, 2020 Share Posted January 26, 2020 4 hours ago, TonyCisseroni said: I see, building the element appears to be the part I was missing. I will look into that a little further. 😊 You’ll need to pass these from your controller into your view. This’ll be when you call the render function in the inc.php file, the {var} are actually just variables as part of the template system. Im on a plane so can’t be more helpful but I’ll post some code when I can. So you’re basically wanting to pass your data to the template in these types of calls: $this->html .= $this->page->buildElement('theftHolder', array( "theft" => $theftArray )); 1 Quote Link to comment Share on other sites More sharing options...
TonyCisseroni Posted January 26, 2020 Author Share Posted January 26, 2020 3 minutes ago, Dave said: You’ll need to pass these from your controller into your view. This’ll be when you call the render function in the inc.php file, the {var} are actually just variables as part of the template system. Im on a plane so can’t be more helpful but I’ll post some code when I can. Hi Dave, I'm starting to get the hang of it. 👍 I'm able to pass the variables from the controller to the view and they are now appearing. Now I have a bug with everything being repeated twice, it's probably something small I'm overlooking. 2 Quote Link to comment Share on other sites More sharing options...
Dave Posted January 26, 2020 Share Posted January 26, 2020 That’s awesome! You’re probably appending to $this->html twice when you may mean to within a conditional 🙂 1 Quote Link to comment 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.