Daniel Posted October 29, 2010 Report Posted October 29, 2010 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 Quote
Administrators simpilot Posted October 29, 2010 Administrators Report Posted October 29, 2010 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. Quote
Daniel Posted October 29, 2010 Author Report Posted October 29, 2010 ok thanks i will see if it works Quote
Daniel Posted October 29, 2010 Author Report Posted October 29, 2010 Where abouts do a put that? What name and where bouts if possible do i put that code. if you could send me the full file with the update. thanks daniel Quote
Administrators simpilot Posted October 29, 2010 Administrators Report Posted October 29, 2010 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. Quote
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.