Ltaest Bids on Front Page

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

Echo the bids some how I suppose.

phpvms.net/docs/api

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

I highly suggest reading a few PHP tutorials

<?php
$array = SchedulesData::GetLatestBids();
$comma_separated = implode(",", $array);
echo $comma_separated;
?>

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

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

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

Did you do a print_r($report) inside the loop to see what variables are avail/

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.

I read the docs on this and it made no sense to me either…

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

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

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

Let me know how this works

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.

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.

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

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

I will take that for now.  Great job!!