nexiss Posted April 7, 2009 Report Share Posted April 7, 2009 Hi All Ok what I am after is have a box on the front page that shows the last 5 or 10 latest bids similar to the latest reports. I have been trying to work out how to do it, my php coding skills are virtually zero! lol I understand the module and .tpl concept of and how the tpl draws the functions from the module etc but it the actual code needed on both the module and tpl files. Would someone be interest in pointing me in the right direction please. Many thanks Karl Quote Link to comment Share on other sites More sharing options...
RogerB Posted April 7, 2009 Report Share Posted April 7, 2009 Echo the bids some how I suppose. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 7, 2009 Administrators Report Share Posted April 7, 2009 phpvms.net/docs/api Quote Link to comment Share on other sites More sharing options...
Strider Posted April 7, 2009 Report Share Posted April 7, 2009 I am now trying to work on the code myself as I think t his would be a great idea to have, but am having some trouble with it: <?php $array = array(SchedulesData::GetBidWithRoute($pilotid, $code, $flightnum)); $comma_separated = implode(",", $array); echo $comma_separated;?> It shows nothing even though I tested it by bidding on a flight, that bid did not show up. Is there something else I should be trying? Cheers Dan C Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 8, 2009 Administrators Report Share Posted April 8, 2009 I highly suggest reading a few PHP tutorials <?php $array = SchedulesData::GetLatestBids(); $comma_separated = implode(",", $array); echo $comma_separated; ?> Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 9, 2009 Author Report Share Posted April 9, 2009 oh cool, I'm getting in a right mess with this lol, I need simple step by step instructions you know like for a 5 year old lmao Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 9, 2009 Author Report Share Posted April 9, 2009 Hi all I have added the code below in the bottom of the Schedules module with the hope that I can call it with my frontpage_recentbids.tpl! Is this right or should I be doing something else? what code do I need in my tpl file to show me the most recent 5 bid on the front page? I thought I would start with this little project as I thought it would be simple, clearly it would seem that when you truly don't understand something its far from simple, I have tried treading php tutorials but until you start doing it it makes no sense! and it dosent expalin codon very well either! function ShowLatestBids() { Template::Set('recentbids', SchedulesData::GetLatestBids($limit=5)); Template::Show('frontpage_recentbids.tpl'); } Appologies if this seems a bit vauge but I really have no idea what I'm doing with php and feel its a little unfair to keep using other peoples work without giving something back myself if I can get it to work Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 13, 2009 Author Report Share Posted April 13, 2009 Ok I have been bashing my head with this and here's where I'm at, I can get the pilot name to show but not the route number or bid ID, the code so far is below: <?php if(!$reports) { echo 'No bids have been made'; return; } foreach($reports as $report) { ?> <p><a href="<?php echo SITE_URL?>/index.php/Schedules/ShowLatestBids/<?php echo $report->bidid;?>">#<?php echo $report->bidid . ' - ' . $report->code.$report->routeid?></a> - <a href="<?php echo SITE_URL?>/index.php/profile/view/<?php echo $report->pilotid?>"><?php echo $report->firstname . ' ' . $report->lastname?></a></p> <?php } ?>code] Could anyone shed some light on it for me please Thank you so much Karl Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 14, 2009 Administrators Report Share Posted April 14, 2009 Did you do a print_r($report) inside the loop to see what variables are avail/ Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 14, 2009 Author Report Share Posted April 14, 2009 Hi Nabeel No I didn't, like I said my php skills are very poor and to be honest with you I have no idea what you mean by print_r($report) and inside the loop! I am just trying to reverse engineer what you have done for the latest pireps on the front page. Quote Link to comment Share on other sites More sharing options...
RogerB Posted April 14, 2009 Report Share Posted April 14, 2009 I read the docs on this and it made no sense to me either..... Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 18, 2009 Author Report Share Posted April 18, 2009 Hi all I am trying really hard here with no success yet, I am starting from the ground up. I have created a folder in the modules folder and then created my .php file with the same name as the folder, the code is below <?php class FrontBids extends CodonModule { public function Controller() { $lastbids = SchedulesData::GetLatestBids(); foreach($lastbids as $lastbid); { echo '<pre>'; print_r($GetLatestBids); echo '</pre>'; } } } ?> but I get the error: Parse error: syntax error, unexpected $end in O:wwwwebrootcoremodulesFrontBidsFrontBids.php on line 19 this is mad I can't even follow Nabeel tutorial without screwing up. Please help Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 18, 2009 Author Report Share Posted April 18, 2009 Ok no panic I have got it to print the variables, I can't tell you how gratifying it is to get just one little snippet of code to work especially with a learning curve as steep as a mountain lol. Lets see if I can get the rest to work now lol Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted April 19, 2009 Administrators Report Share Posted April 19, 2009 Compare to your code and see what I fixed <?php class FrontBids extends CodonModule { public function Controller() { $lastbids = SchedulesData::GetLatestBids(); foreach($lastbids as $lastbid) { echo '<pre>'; print_r($lastbid); echo '</pre>'; } } } ?> [/code Quote Link to comment Share on other sites More sharing options...
RogerB Posted April 19, 2009 Report Share Posted April 19, 2009 Let me know how this works Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 19, 2009 Author Report Share Posted April 19, 2009 hey Nabeel yes thanks that got it. am I right in thinking that if I want to shove the results over to a template for formating and to be called on the front page I use: Template Set: Template show: in the module and then create a template with the echo bit in it? and then call the template into the front page? many thanks Karl PS Roger if I can sort this out I will release it to the public under the modules and addons section so if you don't mind hanging on for a bit I'll let you know as soon as I crack it. Quote Link to comment Share on other sites More sharing options...
RogerB Posted April 20, 2009 Report Share Posted April 20, 2009 Yeah thats great Karl. I was thinking of having the bids show with a background image of something that looks like a flight board. Just a thought. Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 20, 2009 Author Report Share Posted April 20, 2009 Yes nice idea, I have a free day thursday so will sit dawn and have a proper bash at it, will let you know how I go Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 21, 2009 Author Report Share Posted April 21, 2009 ok this is where I'm at with this, I can get the latest bids to show on the front page, but they are not clickable but that is no real problem there. however was hoping to be able to make the bids so that when you click on them it takes you to a page giving a bit more detail and thats when things start to go wrong. The code in my module below generates this error: Parse error: syntax error, unexpected T_SWITCH, expecting ';' or '{' in O:wwwwebrootcoremodulesFrontBidsFrontBids.php on line 8 <?php class FrontBids extends CodonModule { public function Controller() switch($this->get->page) { Template::Set('lastbids', SchedulesData::GetLatestBids()); Template::Show('frontpage_recentbids.tpl'); break; case 'bidreport': $bidid = $this->get->id; $detailbid = SchedulesData::GetBid($bidid); if(!$detailbid) { echo '<p>This BID does not exist!</p>'; return; } Template::Set('detailbid', SchedulesData::GetBid($bidid)); Template::Show('bid_viewreport.tpl'); } } ?> Being a php virgin and learning as I go I am proberbly going about this all wrong how ever if someone wouldn't mind taking a look at the code and putting me right or letting me know if there is an easier way to do what I am trying to do it would be much appreciated Kind regards Karl p.s. If you don't mind having unlinked latest bids on your front page I will upload it to the modules and addons section, let me know Quote Link to comment Share on other sites More sharing options...
RogerB Posted April 21, 2009 Report Share Posted April 21, 2009 I will take that for now. Great job!! Quote Link to comment Share on other sites More sharing options...
nexiss Posted April 22, 2009 Author Report Share Posted April 22, 2009 Ok hope fully this is the last question on this matter I will need to ask lol when I use this script that nabeel put right for me it works a treat and all the placed bids show up <?phpclass FrontBids extends CodonModule { public function Controller() { $lastbids = SchedulesData::GetLatestBids(); foreach($lastbids as $lastbid) { echo '<pre>'; print_r($lastbid); echo '</pre>'; } } } ?> However I created a module and a template with the code below: Module: <?php class FrontBids extends CodonModule { function RecentFrontPage($count = 5) { Template::Set('lastbids', SchedulesData::GetLatestBids($count)); Template::Show('frontpage_recentbids.tpl'); } } ?> and template <?php if(!$lastbids) { echo 'No bids have been made'; return; } foreach($lastbids as $lastbid); { ?> <style type="text/css"> <!-- .style2 { font-family: Arial; font-size: 10px; } --> </style> <p class="style2"><?php echo $lastbid->bidid . ' - ' . $lastbid->code.$lastbid->flightnum.' - '.$lastbid->depicao.' to '.$lastbid->arricao?> </p> <?php } ?> and used <?php MainController::Run('FrontBids', 'RecentFrontPage'); ?> in my front page to display it however it only show's the last bid placed not the last 5, I don't get it as this template is basically a modified recent reports template! I have looked at this and compared it with Nabeels excellent work for many hours now and cannot work out what the problem is. any ideas anyone? Karl 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.