Jump to content
MakeWebGames

Templating system


Sim

Recommended Posts

I been running into issues with the templating system here and there. So hopefully this will give me a better understanding of it.

Data:

array(9) { ["id"]=> string(1) "3" ["name"]=> string(11) "Claw Hammer" ["desc"]=> string(100) "And people only think this Hammer is only good for home improvement. I like bashing heads with them." ["price"]=> string(2) "21" ["type"]=> string(6) "Weapon" ["fileType"]=> string(4) ".png" ["height"]=> string(3) "100" ["width"]=> string(3) "100" ["effects"]=> array(1) { ["effects"]=> string(9) "+8 Damage" } }

 

The PHP:

$data = array(
    "id" => $this->item->item["id"],
    "name" => $this->item->item["name"],
    "desc" => $this->item->item["desc"],
    "price" => $this->item->item["price"],
    "type" => $this->item->itemType,
    "fileType" => $this->item->item["fileType"],
    "height" => $this->item->item["height"],
    "width" => $this->item->item["width"]
    );
    
    
   $data["effects"] = array("effects" => $this->item->getEffect());
   
   var_dump($data);
   //$this->html = $this->item->getHTML();
   $this->html .= $this->page->buildElement('viewItem', $data); 
  }
 

 

The template:


<table class="table table-condensed table-responsive table-bordered table-striped" style="width:250px; margin: auto;">
  <thead>
  <tr>
    <th colspan="2">{name}<br>
                {#if fileType} <img src="content/images/items/{id}{fileType}" height="{height}" width="{width}">{/if}                        
    </th>
  </tr>
 </thead>
 <tbody>
     <tr>
       <td>Type:</td>
       <td>{type}</td>
     </tr>
     <tr>
       <td>Desc:</td>
       <td>{desc}</td>
     </tr>
     <tr>
       <td>Price:</td>
       <td>{price}</td>
     </tr>
     {#each effects}
     <tr>
       <td>Effect:</td>
       <td>{effect}</td>
     </tr>
     {/each}
     </tr>
      <td>
      <button type="submit" class="btn btn-default btn-block" style="margin: 0px;">Buy</button>
      </td>
     </tr>
  </tbody>
</table>

 

It shows the effects tr, but effect is empty, but as the days shows it's not empty. Why and what must be done to display this?

{#each effects}
     <tr>
       <td>Effect:</td>
       <td>{effect}</td>
     </tr>
     {/each}

 

Link to comment
Share on other sites

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.   Paste as plain text instead

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