Learning Joomla 1.5 Extension Development code problem

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Locked
agbandini
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Jul 06, 2008 6:17 pm

Learning Joomla 1.5 Extension Development code problem

Post by agbandini » Wed Sep 30, 2009 6:07 pm

Hi,

I'm trying to develop the reviews component descripted in this book but I'm a problem.
I'm in the chapter 3 (page 36) and I followed all the steps for build the reviews class anche the admin side code for create form and store data. The situation is this (I'm trying to crate the component in my language, italiano) the file with the code is file administrator/components/com_recensioni/admin.recensioni.php

Code: Select all

<?php
defined ('_JEXEC') or die ('Restricted access');

require_once (JApplicationHelper::getPath('admin_html'));
JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
switch ($task) {
	case 'add':
	modificaRecensione ($option);
	break;
	case 'save':
	salvaRecensione($option);
	break;
	}

function modificaRecensione ($option) {
	$row =& JTable::getInstance('recensione','Tabella');
	$lists = array();
	$prenotazioni = array(
		'0' => array('Value' => 'Nessuna', 'text' => 'Nessuna'),
		'1' => array('Value' => 'Accettata', 'text' => 'Accettata'),	
		'2' => array('Value' => 'Suggerita', 'text' => 'Suggerita'),	
		'3' => array('Value' => 'Richiesta', 'text' => 'Richiesta')
		);
	$lists['prenotazioni'] = JHtml::_('select.genericList', $prenotazioni, 'prenotazioni', 'class="inputbox" '. '','value','text',$row->prenotazioni);
	$lists['fumatori'] = JHtml::_('select.booleanlist', 'fumatori', 'class="inputbox"', $row->fumatori);
	$lists['pubblicato'] = JHtml::_('select.booleanlist','pubblicato','class="inputbox"', $row->pubblicato);
	HTML_recensioni::modificaRecensione($row, $lists, $option);
	}
	
function salvaRecensione($option) {
	global $mainframe;
	$row =& JTable::getInstance('recensione', 'Tabella');
	if (!$row->bind(JRequest::get('post'))){
		echo "<script> alert('".$row->getError()."');
		window.history.go(-1); 
		</script>\n";
		exit();
		}
	$row->presentazione = JRequest::getVar( 'presentazione', '', 'post', 'string', JREQUEST_ALLOWRAW );
	$row->recensione = JRequest::getVar( 'recensione', '', 'post','string', JREQUEST_ALLOWRAW );
	if(!$row->data_recensione)
		$row->data_recensione = date('%Y-%m-%d');
	if (!$row->store()){
		echo "<script> alert('".$row->getError()."');
		window.history.go(-1); </script>\n";
		exit();
		}
	$mainframe->redirect('index.php?option=' .$option, 'Recensione Salvata');
}	 
?>

I've also created the admin.recensioni.html.php and It works fine in my back-end.

The problem is: I can save my data in the table of database except for then 'prenotazioni' (reservations, in the book) listbox. Joomla doesn't return me errors but in the Apache's log file I obtain this error:

PHP Notice: Undefined index: value in /var/www/html/test.studioartifex/joomla/libraries/joomla/html/html/select.php on line 76

I need help! Please! And sorry for my english

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 729
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: Learning Joomla 1.5 Extension Development code problem

Post by nailson_imgn » Wed Sep 30, 2009 10:33 pm

Check if you mistyped the prenotazioni field inside your recensione.php file( Il nome del archivio per la vostra tabella ) and also check for the same in your database. If all the fields are correctly typed then the 'bind' function shall retrieve the input values for you.
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

agbandini
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Jul 06, 2008 6:17 pm

Re: Learning Joomla 1.5 Extension Development code problem

Post by agbandini » Wed Sep 30, 2009 11:03 pm

Hi,

I checked for mistyped errors in code but I've not found nothing.
In my opinion The error in the log file of apache is the key.
anyway I enclose the files of my project.

the SQL for the table is

Code: Select all

CREATE TABLE IF NOT EXISTS `jos_recensioni` (
  `id` int(11) NOT NULL auto_increment,
  `nome` varchar(255) NOT NULL,
  `indirizzo` varchar(255) NOT NULL,
  `prenotazioni` varchar(31) NOT NULL,
  `presentazione` text NOT NULL,
  `recensione` text NOT NULL,
  `annotazioni` text NOT NULL,
  `fumatori` tinyint(1) unsigned NOT NULL default '0',
  `carte_di_credito` varchar(255) NOT NULL,
  `cucina` varchar(31) NOT NULL,
  `costo_pranzo` tinyint(3) unsigned NOT NULL default '0',
  `data_recensione` datetime NOT NULL,
  `pubblicato` tinyint(1) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ;
You do not have the required permissions to view the files attached to this post.

User avatar
nailson_imgn
Joomla! Guru
Joomla! Guru
Posts: 729
Joined: Wed Apr 15, 2009 5:33 pm
Location: Fortaleza, CE - Brasil

Re: Learning Joomla 1.5 Extension Development code problem

Post by nailson_imgn » Wed Sep 30, 2009 11:28 pm

Just figured out. You're doing this:

Code: Select all

$prenotazioni = array(
      '0' => array('Value' => 'Nessuna', 'text' => 'Nessuna'),
      '1' => array('Value' => 'Accettata', 'text' => 'Accettata'),   
      '2' => array('Value' => 'Suggerita', 'text' => 'Suggerita'),   
      '3' => array('Value' => 'Richiesta', 'text' => 'Richiesta')
      );
And then this:

Code: Select all

$lists['prenotazioni'] = JHtml::_('select.genericList', $prenotazioni, 'prenotazioni', 'class="inputbox" '. '','value','text',$row->prenotazioni);
You're setting Value as the key, and then you tell JHTML to look for value as the key. As it's not found, you're not getting any value to your options at all.
This is also the cause for the log
PHP Notice: Undefined index: value in /var/www/html/test.studioartifex/joomla/libraries/joomla/html/html/select.php on line 76
In the end, it was jus a mistype...
.
Nailson Oliveira
Técnico de Tecnologia da Informação - Desenvolvedor Joomla!
-----------------------------------------------------------------------------------------

agbandini
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sun Jul 06, 2008 6:17 pm

Re: Learning Joomla 1.5 Extension Development code problem

Post by agbandini » Thu Oct 01, 2009 6:53 am

Ach,

I've often checked and rechecked the code but I missed this error.
Thank you very much! I owe you a beer :D

thanks again
Bye

marcys89
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu Apr 12, 2012 7:52 am

Re: Learning Joomla 1.5 Extension Development code problem

Post by marcys89 » Mon Apr 16, 2012 12:46 pm

I have similar problem. when i try to put in browser http://localhost/joomla/administrator/i ... s&task=add to see result of my work i get blank page...
file admin.review.php from \joomla\administrator\components\com_reviews

Code: Select all

<?php

defined('_JEXEC') or die('acces denied');
required_once(JApplicationHelper::getPath('admin_html'));
JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');
switch($task)
{
	case 'add':
	editReview($option);
	break;
	}
function editReview($option)
{
	$row=&JTable::getInstance('Review','Table');
	$lists=array();
	$reservations=array(
	'0'=>array('value'=>'None Taken', 'text'=>'None Taken'),
	'1'=>array('value'=>'Accepted', 'text'=>'Accepted'),
	'2'=>array('value'=>'Suggested', 'text'=>'Suggested'),
	'3'=>array('value'=>'Required', 'text'=>'Required'),
	);
	$lists['reservations']=JHTML::_('select.genericList', $reservations, 'reservations','class="inputbox"'.'','value','text', $row->reservations);
	$lists['smoking']=JHTML::_('select.booleanlist', 'smoking', 'class="inputbox"', $row->smoking);
	$lists['published']=JHTML::_('select.booleanlist','published','class="inputbox"', $row->published);
	HTML_reviews::editReview($row, $lists, $option);
}
?>


file review.php from \joomla\administrator\components\com_reviews\tables

Code: Select all

<?php

defined('_JEXEC') or die('acces denied');
class TableReview extends JTable{
	var $id=null;
	var $name=null;
	var $address=null;
	var $reservations=null;
	var $quicktake=null;
	var $review=null;
	var $notes=null;
	var $smoking=null;
	var $credit_cards=null;
	var $cuisine=null;
	var $avg_dinner_price=null;
	var $review_date=null;
	var $published=null;
	function __construct(&$db)
	{
		parent::__construct('#__reviews','id' $db);
	}
}



?>
i'm almost sure that I rewrite everything good, so where's the problem?
Thank You for help :)


Locked

Return to “Joomla! 1.5 Coding”