Strict Standards: Creating default object from empty value

Para cualquier duda sobre Joomla! 1.5 que no tenga cabida en alguno de los foros de más abajo.

Moderator: hefesto

Locked
arturojoomla
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Wed Jun 15, 2011 3:53 pm

Strict Standards: Creating default object from empty value

Post by arturojoomla » Thu Jun 16, 2011 10:03 pm

Strict Standards: Creating default object from empty value in /opt/lampp/htdocs/joomla/modules/mod_sp_image_rotator/helper.php on line 28

MuY BUENAS NOCHES me podian ayudar con este poblema que tengo: instale un modulo para visualizar imagenes el mod_sp_image_rotator; pero al momento de publicar el modulo me aprece el error de la linea de arriba estas son las lineas de archivo helper donde me señalan que tengo el error;

defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem.file');
jimport( 'joomla.filesystem.folder' );

abstract class modSPImageRotatorHelper {

static function getList($params) {
$filter = '\.png$|\.gif$|\.jpg$|\.bmp$';
$path = $params->get('path');
$files = JFolder::files(JPATH_BASE.$path,$filter);

$i=0;

$lists = array();

foreach ($files as $file) {
$lists[$i]->title = JFile::stripExt($file); /*aqui esta el erro supuestamente*/
$lists[$i]->image = JURI::base().str_replace(DS,'/',substr($path,1)).'/'.$file;
$i++;
}
return $lists;
}
}

carcam
Joomla! Hero
Joomla! Hero
Posts: 2176
Joined: Sat Dec 29, 2007 1:53 am
Location: Spain
Contact:

Re: Strict Standards: Creating default object from empty val

Post by carcam » Fri Jun 17, 2011 8:46 am

¿Has configurado correctamente el módulo? Ese mensaje de error indica que necesita algún elemento que no está recibiendo.
La web es Mejor Con Joomla ¡envíanos tu sitio en Joomla 4!: https://mejorconjoomla.com/showcase
Twitter: @carcam

13xct
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Mar 26, 2012 2:19 pm

Re: Strict Standards: Creating default object from empty val

Post by 13xct » Mon Mar 26, 2012 2:20 pm

"Creating default object from empty value"

This error tells you your code instantiated a default object (of type stdClass) implicitely. The referenced part of your code most likely looks like

$object->foo = 'bar';

PHP is strict and doesn't accept this, because you didn't create the $object explicitely! The solution to this is rather simple: add the explicit instantiation and you're done! The code should look like:

$object = new stdClass(); // instantiate $object explicitely
$object->foo = 'bar'; // now it's save to do this!

so for your example :

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

jimport('joomla.filesystem.file');
jimport( 'joomla.filesystem.folder' );

abstract class modSPImageRotatorHelper {

static function getList($params) {
$filter = '\.png$|\.gif$|\.jpg$|\.bmp$';
$path = $params->get('path');
$files = JFolder::files(JPATH_BASE.$path,$filter);

$i=0;
$lists = array();

foreach ($files as $file) {
$lists[$i] = new stdClass();
$lists[$i]->title = JFile::stripExt($file);
$lists[$i]->image = JURI::base().str_replace(DS,'/',substr($path,1)).'/'.$file;
$i++;
}
return $lists;
}
}



// enjoy :)
Last edited by hefesto on Mon Mar 26, 2012 3:38 pm, edited 1 time in total.
Reason: Unnecesary commercial links removed. Please post in spanish.


Locked

Return to “Joomla! 1.5”