Jump to content

Ltaest Bids on Front Page


nexiss

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • Administrators

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

<?php

class 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

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