Ciao a tutti,
sto realizzando un modulo ma dove a me sembra tutto ok al browser stranamente non torna..
Facciamo questo gioco:
FIND THE ERROR!
Il problema sicuramente è nella sintassi o nella sequenzialità delle istruzioni.
p.s.: ci sono tutte le intestazioni necessarie per joomla ed i campi del db sono giusti. Se avete Dreamwaver copiate e incollate il codice vedrete tutte le distinzioni di colore.. Ho omesso la variabile $content che sarebbe quella che viene stampata in output, ma quella sono sicuro vada bene.
#################################################
# Don't allow direct acces to the file
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
# Set path to config file
require($mainframe->getCfg( 'absolute_path' )."/administrator/components/com_estateagent/configuration.php");
// Get the right languagefile if it exists
if (file_exists($mosConfig_absolute_path.'/components/com_estateagent/languages/'.$mosConfig_lang.'.php')) {
include($mosConfig_absolute_path.'/components/com_estateagent/languages/'.$mosConfig_lang.'.php');
}else {
include($mosConfig_absolute_path.'/components/com_estateagent/languages/english.php');
}
# Module Parameter Settings
$titlelength = $params->get( 'titlelength', '22' );
$items = 3;
$today = mosCurrentDate( $format="%Y-%m-%d" );
$content = "";
# Set up database query
$query = "SELECT id, cat, type, title, description, rent, price, town, district, publish, publish_up, publish_down
FROM #__estateagent
WHERE "
. "\n ("
. "\n ((publish_up >= '0000-00-00' AND publish_up <= '$today') AND publish_down >= '$today')"
. "\n OR ((publish_up >= '0000-00-00' AND publish_up <= '$today' ) AND (publish_down = '0000-00-00' OR publish_down >= '$today'))"
. "\n OR (publish_up = '0000-00-00' AND publish_down = '0000-00-00')"
. "\n )"
. " AND publish=1 ORDER BY id DESC LIMIT $items";
# Query the database
$database->setQuery( $query );
$record = loadObjectList();
# Set up database query and path for images
$query0 = "SELECT id, path, fname, type, ordering, publish
FROM #__estateagent_images
WHERE objid='$record[0]->id' AND ordering=1";
$img0 = "";
$database->setQuery( $query0 );
$database->loadObject($img0);
$imgpath0 = $mosConfig_live_site . $img0->path . $img0->fname . $img0->type;
$query1 = "SELECT id, path, fname, type, ordering, publish
FROM #__estateagent_images
WHERE objid='$record[1]->id' AND ordering=1";
$img1 = "";
$database->setQuery( $query1 );
$database->loadObject($img1);
$imgpath1 = $mosConfig_live_site . $img1->path . $img1->fname . $img1->type;
$query2 = "SELECT id, path, fname, type, ordering, publish
FROM #__estateagent_images
WHERE objid='$record[2]->id' AND ordering=1";
$img2 = "";
$database->setQuery( $query2 );
$database->loadObject($img2);
$imgpath2 = $mosConfig_live_site . $img2->path . $img2->fname . $img2->type;
#formatting text
$recordtitle0 = $record[0]->title
$recordtitle1 = $record[1]->title
$recordtitle2 = $record[2]->title
if(strlen($recordtitle0) > $titlelength) {
$recordtitle0 = substr($recordtitle0,0,$titlelength);
$recordtitle0 .= "...";
}
if(strlen($recordtitle1) > $titlelength) {
$recordtitle1 = substr($recordtitle1,0,$titlelength);
$recordtitle1 .= "...";
}
if(strlen($recordtitle2) > $titlelength) {
$recordtitle2 = substr($recordtitle2,0,$titlelength);
$recordtitle2 .= "...";
}
##################################################
Secondo voi a livello sequenziale va bene? Non vorrei che ogni volta che faccio una connessione al database mi cancella tutti i record.. Dato che poi ricreo un'altra connessione per le immagini!? Dove sbaglio?