I am in the process of creating my own dashboard module, a couple of quick questions.
Does all of the php code need to be the module/module.php file? Or can most of the code be placed in the template/template.php file?
I’m currently trying to figure out why a form of my is not working, when the form is processed the browser moves onto the process page url but the actual content does not change. Why would this be happening?
If you’re fetching data you should have a class in core/common to handle database interaction.
If you’re manipulating datasets etc to give to the template, it should be in your module.
If it’s purely to create the view output, it should be in your template(s).
As for the issue you’re seeing, it may be easier to set up another route in your module to post data to, then once you’re happy everything’s working you can move things around to post data to the page you want.
Because phpVMS is based on MVC (Model-View-Controller) structure you will need your handling code to be located inside modules (controllers) and classes (models). Where your template (view) files go to template folder. Just type “MVC” in Google and you should find hundreds of top notch articles about MVC as it is that popular.
Best convention I have ever heared of for MVC is “Keep Models Fat and Controllers Thin”.
2. Possibly it is a small mistake, or a larger problem within your code. If you send me your code via private message I am more than happy to help you out.
A small update, I’ve got the function “working” but I have a feeling there is a better way to do this. I have no formal php training so everything I know is from just screwing around.
The goal of this portion of the module is to be able to lookup any metar through a form on the site.
<?php
//This is the Hemisphere Virtual Airlines Crew Resource Center Module
//Use of this module outside of the Hemisphere Virtual Airlines domain is prohibited
//Copyright 2013 - hphvirtual.com Administration
class Dashboard extends CodonModule {
public $title = 'C.R.C. v0.0.1';
public function index()
{
if(!Auth::LoggedIn())
{
$this->set('message', 'You must be logged in to access this feature!');
$this->render('core_error.php');
return;
}
$this->render('dashboard/dashboard.php');
$userinfo = Auth::Displayname();
}
public function metar()
{
if(!Auth::LoggedIn())
{
$this->set('message', 'You must be logged in to access this feature!');
$this->render('core_error.php');
return;
}
{
$this->render('dashboard/dashboard_metar.php');
}
}
}
Thanks for any help or comments on this. Right now the module displays a 404 error when its first brough up, which I’m not too thrilled about but hopefully with a php if statement I can get that figured out.
You can use the following to check whether they’ve arrived after posting the form:
if($_POST){
...
}
So I imagine you’ll probably want to put your $url = … and your iframe inside that.
Also btw you ought to remove those semicolons there outside of the style=“” attribute, and for best browser compatibility you should set height/width attributes using unitless values (i.e. height=“400” rather than height=“400px”) - IE will sometimes have a strop and make things the wrong size.
You can use the following to check whether they’ve arrived after posting the form:
if($_POST){
…
}
So I imagine you’ll probably want to put your $url = … and your iframe inside that.
Also btw you ought to remove those semicolons there outside of the style=“” attribute, and for best browser compatibility you should set height/width attributes using unitless values (i.e. height=“400” rather than height=“400px”) - IE will sometimes have a strop and make things the wrong size.
Thank you very much, the “if” statement was the script needed.
I’ve got some work to do with file_get_contents, I like that fact that I should be able to turn parts of the data into variables and mold them into more useful information than just a metar. But I’ll have to design the data as right now the iframe looks better than the file_get_contents method.
Just one question, I am parsing the XML and sometimes the sky condition <sky_condition sky_cover=“FEW” cloud_base_ft_agl=“3500”/> appears more than once depending on the weather. How can I get each item to show up.