Jump to content

Latest Bids


nexiss

Recommended Posts

Hi all,

I have finaly cracked it (well sort of) not bad for a php virgin lol

I have to say I am no php coder and am stunned that I got this far! which to be honest I wouldn't have done if it wasn't for all you good people on the forum offering advice and Nabeel pointing me in the right direction, and his tutorials

Feel free to use what I have done so far and if you fancy getting it to do what I need it to do (making links Clickable) and don't mind letting me have a copy please feel free, if no one develops it I will try eventually but I've got alot more learning to do first.

Once again thankyou to all those that helped me.

Regards Karl

Latest Bids.zip

Link to comment
Share on other sites

Hi roger

I have re zipped (LatestBidsV01.zip) the files (the ones I'm using) and tested it on a new install on my test machine, it works but only shows the last bid (problem I can't work out), I was hoping that someone would be good enough to pick this up and help us out a little but until they do I am going to have to try and work it out when I get some spare time! unfortunatley real planes at stansted take up much of my time at work lol

also in the zip I have included the test module I used to tap the api based on Nabeels Tutorial which shows the last five bids, to use it, in the core/Modules/FrontBids folder rename "frontBids" to something else and rename "Test" to "FrontBids" then to call it go "http://www.yoursite.com/index.php/FrontBids" it is obviously raw data but you may be able to do something with it. please bare in mind that things are case sensitive

If you have any success please let me know.

Karl

LatestBidsV01.zip

Link to comment
Share on other sites

Roger thats great, I'm not suprised about mistakes lol, in all honesty I'm suprised I got as far as I did! I'm not a coder I'm an aircraft handler lol, but as the old saying goes you don't know unless you try and the best way to learn is to have a go.

look forward to you uploading it, more out of curiosity than anything so that I can see where I went wrong.

Regards

Karl

Link to comment
Share on other sites

I removed the font code, but this is it.

<?php
if(!$lastbids)
{
  echo 'No bids have been made';
  return;
}

foreach($lastbids as $lastbid)

{

      $pilot_info = PilotData::GetPilotData($lastbid->pilotid);

      echo $pilot_info->firstname;

?>

<?php

}

?>

Link to comment
Share on other sites

Hi Roger

I'm a bit confused!  does this code replace the code in the tpl file? if so this is what confuses me as I can't see any code to output the latest bid fields, or has some thing changed in the module aswell,

I did try this code in the tpl file but got a blank output

Link to comment
Share on other sites

Here is what he sent, sorry about that.

<style type="text/css">
<!--
.style2 {
font-family: Arial;
font-size: 10px;
}
-->
</style>
<?php
if(!$lastbids)
{
echo 'No bids have been made';
return;
   
}


foreach($lastbids as $lastbid)
{
      $pilot_info = PilotData::GetPilotData($lastbid->pilotid);
      echo $pilot_info->firstname;


?>


<p class="style2"><?php echo $lastbid->bidid . ' - ' . $lastbid->code.$lastbid->flightnum.' - '.$lastbid->depicao.' to '.$lastbid->arricao?> </p>
<?php
}

?>

Link to comment
Share on other sites

sweet as this works a treat! thankyou roger and Nabeel.

Just to put my confusion to rest, what is the pilot info bit all about?

I would love for someone to put a detailed tutorial up here expalining what the relation ship between templates and modules is, i.e. why certain bits of code go in templates and other bits of code go in the modules and how you would get the contents of a module to show with formating without a template i.e. the hub map. I would love to make lots of addons for this system, it has huge potential but I having trouble just getting my head around the basics.

anyway thanks guys what I was trying to do works now

reagrds karl

Link to comment
Share on other sites

  • Administrators

sweet as this works a treat! thankyou roger and Nabeel.

Just to put my confusion to rest, what is the pilot info bit all about?

I would love for someone to put a detailed tutorial up here expalining what the relation ship between templates and modules is, i.e. why certain bits of code go in templates and other bits of code go in the modules and how you would get the contents of a module to show with formating without a template i.e. the hub map. I would love to make lots of addons for this system, it has huge potential but I having trouble just getting my head around the basics.

anyway thanks guys what I was trying to do works now

reagrds karl

Basically, it goes like this:

mysite.com/index.php/MODULE

then

MODULE -> Template

A module is what's called a "controller", which handles the logic, getting data from a model (the api), and passing that data to a view (template) to output.

Usually, most new programmers will plop everything into one file - all their SQL, their PHP and the HTML, all into one big file, which makes it a mess to extend, and a big mess to debug and eventually the next person who has to look at it, will shoot themselves (I come across alot of this code, it's not pretty).

But this method is called "MVC" programming, "Model-view-controller", where the controller (a module) is the brain for that peice, and it will talk to the model (api) and then send its final data to the view (a template). This way is very powerful as you can shift things around, etc.

In my methodology, I do the main Template::Set() calls in the Controller after getting the data from the model, and then Template::Show(), then in the template, I show the final output. That way, there are no calls to the model within a template, and it's very clear where to look for specific things; if you want to know how variables are set for the template, you check the controller. If you want to see what template is called, you check the controller. If you want to see what data is used, you check the controller, then you check the model since you'll know the exact path it's taking. And you can wrestle around with the template without touching anything in the controller or model. This way it's also really easy to see where bugs really are.

Maybe reading this will help:

http://en.wikipedia.org/wiki/Model-view-controller

http://www.codinghorror.com/blog/archives/001112.html

Link to comment
Share on other sites

Nabeel thanks for that, its very interesting reading. I will have to educate myself in writing php proberly! how people write it like a second language is beyond me, so I give enyone that can write it full credit.

Roger what have you done and whats the problem, I have my bids showing up on the front page, but they are not clickable, thats my next hurdle! take a look at www.nexissair.co.uk

please excuse the skin, I was just learning however am in the process of making a nice clean proffessional looking one as we speak.

If I can help in any way just drop me a line

Karl

Link to comment
Share on other sites

Hi Roger

no I didn't change a thing, I used the original module, and just pasted the code you posted on here into my template, I then just called it into the front page using MainController::Run('FrontBids', 'RecentFrontPage');

FrontBids being the module and RecentFrontPage being the template

Maybe a daft question but is your frontbids module folder definatly labeled "FrontBids" and your module inside that labeled the same? Note the capital letters! the same goes for when you call it in the front page.

Link to comment
Share on other sites

Thats really weird, just incase there is a difference between files I have re attached the files I'm using.

As before the FrontBids folder goes in your core/Modules folder and the Frontpage_recentbids.tpl goes in your lib/skins/yourskin folder.

other than this I really don't know what else to suggest, Nabeel is the pro in this field, time permitting I guess

Latest Front Page Bids.zip

Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...
  • 3 weeks later...

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