
Zitat von
joom_mob-i-co
...- mit so wenig Schnipsel ist das alles nur raten und try and error.
models/auto.php
PHP-Code:
defined('_JEXEC') or die();
jimport('joomla.application.component.model');
/** *Auto Component Auto Model * */
class AutoModelAuto extends JModel {
function _getAutoQuery( &$options ) {
// TODO: Cache on the fingerprint of the arguments
$db = JFactory::getDBO();
$id = @$options['id'];
$select = 'a.*';
$from = '#__auto AS a';
$wheres[] = 'a.published = 1';
$query = "SELECT " . $select .
"\n FROM " . $from .
"\n WHERE " . implode( "\n AND ", $wheres );
// hier beginnen und enden o.g. if-Schleifen mit $flag
return $query;
}
function getAutoList( $options=array() )
{
$query = $this->_getAutoQuery( $options );
$result = $this->_getList( $query );
return @$result;
}
}
views/auto/view.html
PHP-Code:
jimport( 'joomla.application.component.view');
/**
* HTML View class for the auto Component
*/
class AutoViewAuto extends JView
{
function display($tpl = null)
{
$model = &$this->getModel();
$rows = $model->getAutoList();
$this->assignRef('rows' , $rows);
// hier die o.g. Weitergabe ... und print_r($flag); das query-string ausgibt
parent::display($tpl);
}
}
views/default.php
PHP-Code:
<?php
// hier Ausgabe: if ((isset($this->flag)) AND ($this->flag == 1)) { ...
?>
<h1><?php echo "Überschrift - default.php-Template"; ?></h1>
<ul>
<?
// Auslesen der Datensätze im Array
foreach ($this->rows as $row) {
?>
<li><?php echo $row->text; ?> <small><em>(<?php echo $row->hersteller; ?>)</em></small><br>
<a href="<?php echo $row->photo_gross; ?>" onclick="FensterOeffnen(this.href); return false"><img src=<?php echo $row->photo_klein; ?>></a>
</li>
<?php
}
Lesezeichen