Hallo zusammen,
kann ich bei einem neuen DCA-Container, der als Backend-Modul eingebunden wird, festlegen, wie viele Elemente pro Seite angezeigt werden?
Bzw. wird hier überhaupt ab einer bestimmten Anzahl von Einträgen auf mehrere Seiten verteilt?
Hallo zusammen,
kann ich bei einem neuen DCA-Container, der als Backend-Modul eingebunden wird, festlegen, wie viele Elemente pro Seite angezeigt werden?
Bzw. wird hier überhaupt ab einer bestimmten Anzahl von Einträgen auf mehrere Seiten verteilt?
(ich glaube) nein (selbst festlegen) und ja (werden begrenzt).
Was hast Du denn bisher gemacht/ausprobiert und was funktioniert nicht so, wie Du es gerne hättest?
Contao-Community-Treff Bayern: http://www.contao-bayern.de
Zuvor hatte ich die Situation noch nicht, dass ich in einem Container sehr viele Einträge hatte.
Jetzt habe ich allerdings den Fall, dass in einem Container in Zukunft bei mir sehr viele Einträge (>200) sein werden.
Aus diesem Grund würde ich mir prinzipiell einfach nur einen Umbruch auf mehrere Seiten wünschen.
Weißt du wieviele Einträge pro Seite denn maximal angezeigt werden?
Wieviele Einträge pro Seite angezeigt werden, kann in den System Einstellungen eingestellt werden. Evt. kannst du diesen globalen Wert dann auch per onload_callback dynamisch ändern - habe ich bisher nie versucht.
Aha, keine Ahnung wie du das geschafft hast Zeige mal einen Screenshot davon und dein DCA.
Wovon genau benötigst du denn einen Screenshot?
Mein DCA sieht grob so aus:
Die Einstellungen "Elemente pro Seite" und "Maximum Datensätze pro Seite" stehen bei mir beide auf 30PHP-Code:
<?php
$GLOBALS['TL_DCA']['tl_meindca'] = array
(
// Config
'config' => array
(
'dataContainer' => 'Table',
'sql' => array
(
'keys' => array
(
'id' => 'primary'
)
),
'onsubmit_callback' => array(array('tl_meindca', 'onsubmit_callback'))
),
// List
'list' => array
(
'sorting' => array
(
'mode' => 1,
'flag' => 11,
'fields' => array('artno'),
'panelLayout' => 'search'
),
'label' => array(
'fields' => array('id', 'artno', 'titlede'),
'label_callback' => array('tl_meindca', 'label_callback'),
'showColumns' => true
),
'operations' => array
(
'edit' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['edit'],
'href' => 'act=edit',
'icon' => 'edit.gif'
),
'copy' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['copy'],
'href' => 'act=copy',
'icon' => 'copy.gif',
'button_callback' => array('tl_meindca', 'copyProduct')
),
'delete' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['delete'],
'href' => 'act=delete',
'icon' => 'delete.gif',
'attributes' => 'onclick="if(!confirm(\'' . $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
),
'toggle' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['toggle'],
'icon' => 'visible.svg',
'attributes' => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
'button_callback' => array('tl_meindca', 'toggleIcon')
)
)
),
// Palettes
'palettes' => array
(
'default' => '{basicinfo_legend}, artno, titlede, titleen; {category_legend}, category; {description_legend}, shortdescriptionde, shortdescriptionen, descriptionde, descriptionen; {image_legend}, imageSRC;'
),
// Fields
'fields' => array
(
'id' => array
(
'sql' => "int(10) unsigned NOT NULL auto_increment"
),
'tstamp' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['tstamp'],
'eval' => array('rgxp'=>'date'),
'flag' => 5,
'sql' => "int(10) unsigned NOT NULL default '0'"
),
'published' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['published'],
'filter' => true,
'inputType' => 'checkbox',
'sql' => "char(1) NOT NULL default '0'"
),
'artno' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['artno'],
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'tl_class'=>'w50', 'doNotCopy'=>true),
'search' => true,
'sql' => "varchar(255) NOT NULL default ''"
),
'titlede' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['titlede'],
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'tl_class'=>'clr w50', 'doNotCopy'=>true),
'search' => true,
'sql' => "varchar(255) NOT NULL default ''"
),
'titleen' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['titleen'],
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'tl_class'=>'w50', 'doNotCopy'=>true),
'sql' => "varchar(255) NOT NULL default ''"
),
'category' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['category'],
'inputType' => 'multiColumnWizard',
'eval' => array(
'columnFields' => [
'data' => [
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['category']['data'],
'inputType' => 'select',
'foreignKey'=> 'tl_dcacategories.categoryde',
'eval' => ['includeBlankOption'=>true, 'allowHtml' => false, 'style'=>'width:100%']
]
],
'buttons' => array('copy'=>false, 'up'=>false, 'down'=>false),
'tl_class' => 'w50'
),
'sql' => "blob NULL"
),
'shortdescriptionde' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['shortdescriptionde'],
'inputType' => 'textarea',
'eval' => array('mandatory'=>true, 'tl_class'=>'w50', 'style'=>'resize: none'),
'sql' => "varchar(255) NOT NULL default ''"
),
'shortdescriptionen' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['shortdescriptionen'],
'inputType' => 'text',
'eval' => array('mandatory'=>true, 'tl_class'=>'w50', 'style'=>'resize: none'),
'sql' => "varchar(255) NOT NULL default ''"
),
'descriptionde' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['descriptionde'],
'inputType' => 'textarea',
'eval' => array('mandatory'=>true, 'rte'=>'tinyMCE', 'style'=>'resize: none', 'tl_class'=>'clr'),
'sql' => "mediumtext NOT NULL default ''"
),
'descriptionen' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['descriptionen'],
'inputType' => 'textarea',
'eval' => array('mandatory'=>true, 'rte'=>'tinyMCE', 'style'=>'resize: none', 'tl_class'=>'clr'),
'sql' => "mediumtext NOT NULL default ''"
),
'imageSRC' => array
(
'label' => $GLOBALS['TL_LANG']['tl_meindca']['imageSRC'],
'inputType' => 'fileTree',
'eval' => array('mandatory'=>true, 'multiple'=>true, 'orderField'=>'orderImageSRC', 'files'=>true, 'filesOnly'=>true, 'isGallery'=>true, 'extensions'=>'png', 'fieldType'=>'checkbox', 'path'=>'files/files/Produkte'),
'sql' => "blob NULL"
),
'orderImageSRC' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_meindca']['sortOrder'],
'sql' => "blob NULL"
),
)
);
class tl_meindca extends Backend {
public function toggleIcon($row, $href, $label, $title, $icon, $attributes) {
$this->import('BackendUser', 'User');
if (strlen($this->Input->get('tid'))) {
$this->toggleVisibility($this->Input->get('tid'), ($this->Input->get('state') == 0));
$this->redirect($this->getReferer());
}
$href .= '&id='.$this->Input->get('id').'&tid='.$row['id'].'&state='.$row[''];
if (!$row['published']){
$icon = 'invisible.gif';
}
return '<a href="'.$this->addToUrl($href).'" title="'.specialchars($title).'"'.$attributes.'>'.$this->generateImage($icon, $label).'</a> ';
}
public function toggleVisibility($intId, $blnPublished) {
$this->createInitialVersion('tl_meindca', $intId);
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_meindca']['fields']['published']['save_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_meindca']['fields']['published']['save_callback'] as $callback) {
$this->import($callback[0]);
$blnPublished = $this->$callback[0]->$callback[1]($blnPublished, $this);
}
}
// Update the database
$this->Database->prepare("UPDATE tl_meindca SET tstamp=". time() .", published='" . ($blnPublished ? '' : '1') . "' WHERE id=?")
->execute($intId);
$this->createNewVersion('tl_meindca', $intId);
}
// Duplicate Product
public function copyProduct($row, $href, $label, $title, $icon, $attributes, $table) {
if ($GLOBALS['TL_DCA'][$table]['config']['closed']) {
return '';
}
return '<a href="'.$this->addToUrl($href.'&id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon, $label).'</a> ';
}
// Label Callback
public function label_callback($row, $label, DataContainer $dc, $args) {
// Replace Image
if($args[0]){
$product = \ProductModel::findById($args[0]);
if($product->orderImageSRC) {
$src = \FilesModel::findByUuid(unserialize($product->orderImageSRC)[0])->path;
$args[0] = '<img src=' . $src . ' style="max-width:100px;">';
}
}
return $args;
}
// OnSubmit Callback
public function onsubmit_callback(DataContainer $dc) {
$logMsg = BackendUser::getInstance()->username . " updated product " . $dc->activeRecord->artno . " (ID: " . $dc->activeRecord->id . ").";
\System::log($logMsg, __METHOD__, TL_GENERAL);
}
}
Screenshot der Übersicht deiner DCA Einträge.
Hier ist noch der Screenshot der Einträge. Ich hoffe du kannst damit etwas anfangen.
img.jpg
Ah, dir fehlt das "limit" Panel.PHP-Code:
'panelLayout' => 'search,limit',
Das wars, vielen Dank !
Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
Lesezeichen