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