The Joomla! Forum ™



Forum rules


Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.



Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Sep 30, 2009 6:07 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Jul 06, 2008 6:17 pm
Posts: 18
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:
<?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


Top
 Profile  
 
PostPosted: Wed Sep 30, 2009 10:33 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Apr 15, 2009 5:33 pm
Posts: 720
Location: Fortaleza, CE - Brasil
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
Imagine Comunicação Digital - http://www.imagineseusite.com.br/
-----------------------------------------------------------------------------------------


Top
 Profile  
 
PostPosted: Wed Sep 30, 2009 11:03 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Jul 06, 2008 6:17 pm
Posts: 18
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:
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.


Top
 Profile  
 
PostPosted: Wed Sep 30, 2009 11:28 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Wed Apr 15, 2009 5:33 pm
Posts: 720
Location: Fortaleza, CE - Brasil
Just figured out. You're doing this:
Code:
$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:
$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
Quote:
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
Imagine Comunicação Digital - http://www.imagineseusite.com.br/
-----------------------------------------------------------------------------------------


Top
 Profile  
 
PostPosted: Thu Oct 01, 2009 6:53 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Jul 06, 2008 6:17 pm
Posts: 18
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


Top
 Profile  
 
PostPosted: Mon Apr 16, 2012 12:46 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Thu Apr 12, 2012 7:52 am
Posts: 3
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:
<?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:
<?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 :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 



Who is online

Users browsing this forum: Yahoo [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group