MVC design minus the M - Joomla! Forum - community, help and support
up point i've been doing component development on 2.5 without doing , taking advantage of mvc.
following hello world tutorial (http://docs.joomla.org/developing_a_mod ... troduction) i've created own component pieces need have couple of questions.
right view have: site/views/mycomponent/view.html.php
then have site\views\mycomponent\tmpl\default.php has front end code.
my first question view.html.php. code need?
now next problem don't use models @ all. i'm not sure kind of file create , where. plus how used?
for example view default.php: site\views\mycomponent\tmpl\default.php
from understand should put queries in model. have update queries in controller. tried:
this model created here: site/models/mycomponent.php. thought called "getuserid" in view default.php (or add accordingly controller). doesn't seem work. in advance.
following hello world tutorial (http://docs.joomla.org/developing_a_mod ... troduction) i've created own component pieces need have couple of questions.
right view have: site/views/mycomponent/view.html.php
code: select all
function display($tpl = null)
{
// display view
parent::display($tpl);
}then have site\views\mycomponent\tmpl\default.php has front end code.
my first question view.html.php. code need?
now next problem don't use models @ all. i'm not sure kind of file create , where. plus how used?
for example view default.php: site\views\mycomponent\tmpl\default.php
code: select all
// dont allow direct linking
defined('_jexec') or die('direct access location not allowed.');
// user , session data.
$user =& jfactory::getuser();
$db =& jfactory::getdbo();
$doc =& jfactory::getdocument();
//list cameras - needed active cameras table
$query_camera_name = "select camera_name, camera_status, camera_quality, email_notice, camera_hash, camera_type, camera_sensitivity, camera_user, camera_pass, camera_ip, camera_port #__cameras user_id=".(int)($user->id)." , camera_status!='deleted'";
$db->setquery($query_camera_name);
//get number of cameras - needed active cameras table
$db->query();
$num_rows = $db->getnumrows();
// can use array names loadassoclist.
$result_cameras = $db->loadassoclist();
//get user(id) hash - needed active cameras table
$query = 'select id_hash `#__users`';
$query .= ' `user_id` = ' . (int)($user->id);
$db->setquery($query);
$id_hash = $db->loadresult();
//then jquery ajax code , html code
from understand should put queries in model. have update queries in controller. tried:
code: select all
// import joomla modelitem library
jimport('joomla.application.component.modelitem');
/**
* helloworld model
*/
class helloworldmodelhelloworld extends jmodelitem
{
public function getuserid()
{
$query = 'select id_hash `#__users`';
$query .= ' `user_id` = ' . (int)($user->id);
$db->setquery($query);
return $db->loadresult();
}
}this model created here: site/models/mycomponent.php. thought called "getuserid" in view default.php (or add accordingly controller). doesn't seem work. in advance.
Comments
Post a Comment