i got fatal error when creating component , i'm noob joomla!
let's have component com_shirts , code
my code in administrator/component/com_shirts/controllers/code.php
my code in administrator/component/com_shirts/controllers/codes.php
my code in administrator/component/com_shirts/models/code.php
my code in administrator/component/com_shirts/models/codes.php
my code in administrator/component/com_shirts/tables/code.php
my code in administrator/component/com_shirts/views/codes/view.html.php
my code in administrator/component/com_shirts/views/codes/tmpl/default.php
my code in administrator/component/com_shirts/views/code/tmpl/edit.php
my code in administrator/component/com_shirts/views/code/view.html.php
and when enter on component page error
"php fatal error: call member function getkeyname() on non-object in /var/www/joomla/libraries/joomla/application/component/controllerform.php on line 393"
, dont know how resolve this
let's have component com_shirts , code
my code in administrator/component/com_shirts/controllers/code.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.controllerform');
class shirtscontrollercode extends jcontrollerform{
protected $view_list = 'codes';
}
my code in administrator/component/com_shirts/controllers/codes.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.controlleradmin');
class shirtscontrollercodes extends jcontrolleradmin{
protected $text_prefix = 'com_shirts';
function getmodel($name='code', $prefix='shirtsmodel', $config=array('ignore_request'=>true)){
$model = parent::getmodel($name, $prefix, $config);
return $model;
}
}
my code in administrator/component/com_shirts/models/code.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.modeladmin');
class shirtsmodelcode extends jmodeladmin{
function gettable($type='code', $prefix='shirtstable', $config=array()){
return jtable::getinstance($type, $prefix, $config);
}
function getform($data=array(), $loaddata=true){
$form = $this->loadform();
return $form;
}
}
my code in administrator/component/com_shirts/models/codes.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.modellist');
class shirtsmodelcodes extends jmodellist{
function getitems(){
$items = parent::getitems();
foreach($items &$item){
$item->url = 'index.php?option=com_shirts&task=code.edit&code_id='.$item->code_id;
$item->event_description = substr($item->code_desc, 0);
}
return $items;
}
function getlistquery(){
$query = parent::getlistquery();
$query->select('*');
$query->from('#__shirts_codes');
return $query;
}
}
my code in administrator/component/com_shirts/tables/code.php
code: select all
<?php
defined('_jexec') or die;
class shirtstablecode extends jtable{
public function __construct(&$dbo){
parent::__construct('#__shirts_codes', 'code_id', $dbo);
}
}
my code in administrator/component/com_shirts/views/codes/view.html.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.view');
class shirtsviewcodes extends jview{
protected $codes;
function display($tmpl=null){
$this->codes = $this->get('items');
$this->toolbar();
parent::display($tmpl);
}
function toolbar(){
jtoolbarhelper::title(jtext::_('header'));
jtoolbarhelper::addnew('code.add');
jtoolbarhelper::editlist('code.edit');
jtoolbarhelper::divider();
jtoolbarhelper::publishlist('codes.publish');
jtoolbarhelper::unpublishlist('codes.unpublish');
jtoolbarhelper::divider();
jtoolbarhelper::archivelist('codes.archive');
jtoolbarhelper::trash('codes.trash');
jtoolbarhelper::divider();
}
}
my code in administrator/component/com_shirts/views/codes/tmpl/default.php
code: select all
<?php defined('_jexec') or die; ?>
<form action="index.php?option=com_shirts&view=codes" method="post" name="adminform" id="adminform">
<table class="adminlist">
<thead>
<tr>
<th style="width: 1%">
<input type="checkbox" name="checkall-toggle" value="" onclick="checkall(this)" />
</th>
</tr>
</thead>
<tbody>
<?php foreach($this->codes $i=>$code):
$url = 'index.php?option=com_shirts&view=code&task=code.edit&event_id='.$code->code_id;
?>
<tr class="row<?php echo $i%2; ?>">
<td class="center">
<?php echo jhtml::_('grid.id', $i, $code->code_id); ?>
</td>
<td class="center">
<a href="<?php echo $code->url; ?>">
<?php echo $this->escape($code->code); ?>
</a>
</td>
<td>
<a href="<?php echo $code->url; ?>">
<?php echo $this->escape($code->code_desc); ?>
</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<?php echo jhtml::_('form.token'); ?>
</form>
my code in administrator/component/com_shirts/views/code/tmpl/edit.php
code: select all
<?php defined('_jexec') or die; ?>
<form
method="post"
name="adminform"
class="form-validate"
action="index.php?option=com_shirts&code_id=<?php echo $this->code->code_id; ?>"
>
<div class="width-50 fltlft">
<fieldset class="adminform">
<ul class="adminformlist">
<?php foreach($this->form->getfieldset('required') $field): ?>
<li>
<?php echo $field->label; ?>
<?php echo $field->input; ?>
</li>
<?php endforeach; ?>
</fieldset>
</div>
<div class="width-40 fltrt">
<fieldset class="adminform">
<ul class="adminformlist">
<?php foreach($this->form->getfieldset('optional') $field): ?>
<li>
<?php echo $field->label; ?>
<?php echo $field->input; ?>
</li>
<?php endforeach; ?>
</ul>
</fieldset>
</div>
<input type="hidden" name="task" value="" />
<?php echo jhtml::_('form.token'); ?>
</form>
my code in administrator/component/com_shirts/views/code/view.html.php
code: select all
<?php
defined('_jexec') or die;
jimport('joomla.application.component.view');
class shirtsviewcode extends jview{
protected $code;
protected $form;
function display($tmpl=null){
$this->event = $this->get('item');
$this->form = $this->get('form');
$this->toolbar();
parent::display($tmpl);
}
function toolbar(){
if($this->code->code_id){
jtoolbarhelper::title(jtext::_('com_shirts_edit'));
}else{
jtoolbarhelper::title(jtext::_('com_shirts_add'));
}
jtoolbarhelper::apply('code.apply', 'jtoolbar_apply');
jtoolbarhelper::save('code.save', 'jtoolbar_save');
jtoolbarhelper::save2new('code.save', 'jtoolbar_save_and_new');
jtoolbarhelper::divider();
jtoolbarhelper::cancel('code.cancel');
}
}
and when enter on component page error
"php fatal error: call member function getkeyname() on non-object in /var/www/joomla/libraries/joomla/application/component/controllerform.php on line 393"
, dont know how resolve this
Comments
Post a Comment