Jump to content

Recommended Posts

Posted

ok i have looked about in the other post's and i find it hard to find the code and where to put this code so it does not show any hub's or Lists. So it is just one list of pilots.

If possible could you please reply with the code and Where to put it.

Regards

Daniel

  • Administrators
Posted

In your module use

$this->set('pilots', PilotData::getAllPilots());

to pass the data to your template, then in your template you can use a

print_r($pilots);

temporarily to see what data is available to you in the variable.

Then it is just a matter of building you display for the data as you would like.

A simple table example could be

<table>
<tr>
 <td>Pilot</td>
 <td>Country</td>
</tr>
<?php
 foreach($pilots as $pilot)
  {
   echo '<tr>';
   echo '<td>'.$pilot->firstname.' '.$pilot->lastname.'</td>';
   echo '<td>'.$pilot->location.'</td>';
   echo '</tr>';
  }
?>
</table>

This is off the top of my head so it may need to be cleaned up a little but you should be able to build your list from here.

  • Administrators
Posted

Build a new module:

First create a folder named Listing in your core/modules folder, then inside of that folder create a file named Listing.php and insert the following in it;

<?php
class Listing extends CodonModule  {

   public function index() {
       $this->set('pilots', PilotData::getAllPilots());
       $this->show('pilotslist.tpl');
   }
}

Then create a new template in your skin folder called pilotslist.php and insert the following in it;

<table>
<tr>
 <td>Pilot</td>
 <td>Country</td>
</tr>
<?php
 foreach($pilots as $pilot)
  {
   echo '<tr>';
   echo '<td>'.$pilot->firstname.' '.$pilot->lastname.'</td>';
   echo '<td>'.$pilot->location.'</td>';
   echo '</tr>';
  }
?>
</table>

Then point your browser to

www.yoursite.com/index.php/Listing

It will show a listing of all the pilots names and the country abreviation from the database. You can throw a

print_r($pilots);

in the template to see what data is available to you but I believe it will supply everything in the pilots table to you for your use in a table of your liking.

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

  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.

Loading...
×
×
  • Create New...