Ergebnis 1 bis 5 von 5

Thema: Attempted to load class "Table" from the global namespace

  1. #1
    Contao-Nutzer
    Registriert seit
    02.12.2017.
    Beiträge
    140

    Standard Attempted to load class "Table" from the global namespace

    Hallo zusammen,

    ich versuche aktuell eine private Erweiterung (diese habe ich vor einigen Jahren unter Contao 4 entwickelt) kompatibel für Contao 5 zu machen.
    Grob zusammengefasst lassen sich über diese Erweiterung im Backend verschiedene Produkte und Produktkategorien anlegen und dann im Frontend in einer Produktübersicht und in einer Produkt-Detailseite ausspielen.

    Ich habe zwei Backend-Module hinzugefügt, in denen die Produkte und die Kategorien verwaltet werden können:

    config.php:
    PHP-Code:
    // Backend Modules
    $GLOBALS['BE_MOD']['extension']['products'] = [
      
    'tables' => ['tl_products'],
    ];

    $GLOBALS['BE_MOD']['extension']['categories'] = [
      
    'tables' => ['tl_categories'],
    ]; 
    Wenn ich jedoch im Backend nun auf eine der beiden Kategorien gehe, erhalte ich folgenden Fehler:
    PHP-Code:
    Symfony\Component\ErrorHandler\Error\ClassNotFoundError:
    Attempted to load class "Table" from the global namespace.
    Did you forget a "use" statement for e.g"Symfony\Component\Console\Helper\Table""Spatie\SchemaOrg\Table""League\CommonMark\Extension\Table\Table""Doctrine\ORM\Mapping\Table" or "Doctrine\DBAL\Schema\Table"?

      
    at vendor/contao/core-bundle/contao/classes/Backend.php:293
      at Contao
    \Backend->getBackendModule()
         (
    vendor/contao/core-bundle/contao/controllers/BackendMain.php:146)
      
    at Contao\BackendMain->run()
         (
    vendor/contao/core-bundle/src/Controller/BackendController.php:44)
      
    at Contao\CoreBundle\Controller\BackendController->mainAction()
         (
    vendor/symfony/http-kernel/HttpKernel.php:181)
      
    at Symfony\Component\HttpKernel\HttpKernel->handleRaw()
         (
    vendor/symfony/http-kernel/HttpKernel.php:76)
      
    at Symfony\Component\HttpKernel\HttpKernel->handle()
         (
    vendor/symfony/http-kernel/Kernel.php:197)
      
    at Symfony\Component\HttpKernel\Kernel->handle()
         (
    web/index.php:44
    Ich kann diesen Fehler allerdings nicht wirklich zuordnen, was mir die Fehlersuche sehr erschwert.
    Habt ihr vielleicht einen Ansatz, wie ich auf den Fehler kommen könnte?

  2. #2
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.114
    Partner-ID
    10107

    Standard

    Der dataContainer eines deiner DCAs stimmt nicht. Poste die DCAs.
    » sponsor me via GitHub or PayPal or Revolut

  3. #3
    Contao-Nutzer
    Registriert seit
    02.12.2017.
    Beiträge
    140

    Standard

    Gerne.
    Meine DCAs sind:

    tl_content.php:
    PHP-Code:
    <?php
    use Contao\DC_Table;
    use 
    Contao\Backend;

    // Palettes
    $GLOBALS['TL_DCA']['tl_content']['palettes']['productList'] = '{type_legend},type,headline;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop';
    $GLOBALS['TL_DCA']['tl_content']['palettes']['productPreview'] = '{type_legend},type,headline;{product_legend},products;{template_legend:hide},customTpl;{protected_legend:hide},protected;{expert_legend:hide},guests,cssID;{invisible_legend:hide},invisible,start,stop';

    // Fields
    $GLOBALS['TL_DCA']['tl_content']['fields']['products'] = array(
      
    /*'label'                     => $GLOBALS['TL_LANG']['tl_content']['products'],*/
      
    'inputType'                 => 'multiColumnWizard',
      
    'eval'                      => array(
        
    'columnFields'  => [
          
    'product' => [
            
    /*'label'     => $GLOBALS['TL_LANG']['tl_content']['products']['product'],*/
            
    'inputType' => 'select',
            
    'foreignKey'=> 'tl_products.artno',
            
    'eval'      => ['allowHtml' => false'style' => 'width: 100%; max-width:200px']
          ]
        ]
      ),
      
    'sql'               => "blob NULL"
    );
    tl_form.php:
    PHP-Code:
    <?php
    use Contao\DC_Table;
    use 
    Contao\Backend;

    // remove regex from recipient field to allow inserttags there
    $GLOBALS['TL_DCA']['tl_form']['fields']['recipient']['eval']['rgxp'] = '';

    ?>
    tl_categories.php:
    PHP-Code:
    <?php
    use Contao\DC_Table;
    use 
    Contao\Backend;

    $GLOBALS['TL_DCA']['tl_categories'] = array
    (
      
    // Config
      
    'config' => array
      (
        
    'dataContainer'                     => 'Table',
        
    'sql'                                             => array
        (
          
    'keys'                                         => array
          (
            
    'id'                                         => 'primary'
          
    )
        )
      ),

      
    // List
      
    'list' => array
      (
        
    'sorting' => array
        (
          
    'mode'                            => 5,
          
    'fields'                  => array('sorting'),
          
    'paste_button_callback'   => array('tl_categories''pasteElement')
        ),
        
    'label' => array(
          
    'fields'                  => array('categoryde''categoryen'),
          
    'showColumns'             => true
        
    ),
        
    'operations' => array
        (
          
    'edit' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_categories']['edit'],
            
    'href'                => 'act=edit',
            
    'icon'                => 'edit.gif'
          
    ),
          
    'cut' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_categories']['cut'],
            
    'href'                => 'act=paste&mode=cut',
            
    'icon'                => 'cut.svg',
            
    'attributes'          => 'onclick="Backend.getScrollOffset()"',
            
    'button_callback'     => array('tl_categories''cutCategory')
          ),
          
    'delete' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_categories']['delete'],
            
    'href'                => 'act=delete',
            
    'icon'                => 'delete.gif',
            
    'attributes'          => 'onclick="if(!confirm(\'' $GLOBALS['TL_LANG']['MSC']['deleteConfirm'] . '\'))return false;Backend.getScrollOffset()"'
          
    )
        )
      ),

      
    // Palettes
      
    'palettes' => array
      (
        
    'default'                   => '{basicinfo_legend}, categoryde, categoryen;'
      
    ),

      
    // Fields
      
    'fields' => array
      (
        
    'id' => array
        (
          
    'sql'                     => "int(100) unsigned NOT NULL auto_increment"
        
    ),
        
    'pid' => array
        (
          
    'sql'                     => "int(100) unsigned NOT NULL default 0",
        ),
        
    'sorting' => array
        (
          
    'sql'                     => "int(100) unsigned NOT NULL default 0"
        
    ),
        
    'tstamp' => array
        (
          
    'label'                     => $GLOBALS['TL_LANG']['tl_categories']['tstamp'],
          
    'eval'                    => array('rgxp'=>'date'),
          
    'flag'                    => 5,
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'"
        
    ),
        
    'categoryde' => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_categories']['categoryde'],
            
    'inputType'             => 'text',
            
    'eval'                                  => array('mandatory'=>true'tl_class'=>'w50'),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'categoryen' => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_categories']['categoryen'],
            
    'inputType'             => 'text',
            
    'eval'                                  => array('mandatory'=>true'tl_class'=>'w50'),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    )
      )
    );

    class 
    tl_categories extends Backend {
      public function 
    cutCategory($row$href$label$title$icon$attributes){
        
    $objPage = \BundleProvider\ContaoProductsBundle\Model\CategoryModel::findById($row['id']);

            return 
    '<a href="'.$this->addToUrl($href.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon$label).'</a> ';
      }

      public function 
    pasteElement(DataContainer $dc$row$table$cr$arrClipboard=null){
            
    $imagePasteAfter Image::getHtml('pasteafter.gif'sprintf($GLOBALS['TL_LANG'][$table]['pasteafter'][1], $row['id']));

        
    $objPage = \BundleProvider\ContaoProductsBundle\Model\CategoryModel::findById($row['pid']);
        return 
    '<a href="'.$this->addToUrl('act='.$arrClipboard['mode'].'&amp;mode=1&amp;pid='.$row['id'].(!\is_array($arrClipboard['id']) ? '&amp;id='.$arrClipboard['id'] : '')).'" title="'.Contao\StringUtil::specialchars(sprintf($GLOBALS['TL_LANG'][$dc->table]['pasteafter'][1], $row['id'])).'" onclick="Backend.getScrollOffset()">'.$imagePasteAfter.'</a> ';
        }
    }

    ?>
    tl_products.php:
    PHP-Code:
    <?php
    use Contao\DC_Table;
    use 
    Contao\Backend;

    $GLOBALS['TL_DCA']['tl_products'] = array
    (
      
    // Config
      
    'config' => array
      (
        
    'dataContainer'                     => 'Table',
        
    'sql'                                             => array
        (
          
    'keys'                                         => array
          (
            
    'id'                                         => 'primary'
          
    )
        ),
        
    'onsubmit_callback'         =>  array(array('tl_products''onsubmit_callback'))
      ),

      
    // List
      
    'list' => array
      (
        
    'sorting' => array
        (
          
    'mode'                            => 1,
          
    'flag'                                      => 11,
          
    'fields'                                  => array('artno'),
          
    'panelLayout'             => 'filter;search,limit'
        
    ),

        
    'label' => array(
          
    'fields'                  => array('id''artno''titlede'),
          
    'label_callback'          => array('tl_products''label_callback'),
          
    'showColumns'             => true
        
    ),
        
    'operations' => array
        (
          
    'edit' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_products']['edit'],
            
    'href'                => 'act=edit',
            
    'icon'                => 'edit.gif'
          
    ),
          
    'copy' => array
          (
            
    'label'             => &$GLOBALS['TL_LANG']['tl_products']['copy'],
            
    'href'              => 'act=copy',
            
    'icon'              => 'copy.gif',
            
    'button_callback'     => array('tl_products''copyProduct')
          ),
          
    'delete' => array
          (
            
    'label'               => &$GLOBALS['TL_LANG']['tl_products']['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_products']['toggle'],
                    
    'icon'                => 'visible.svg',
                    
    'attributes'          => 'onclick="Backend.getScrollOffset();return AjaxRequest.toggleVisibility(this,%s)"',
                    
    'button_callback'     => array('tl_products''toggleIcon')
                )
        )
      ),

      
    // Palettes
      
    'palettes' => array
      (
        
    'default'                   => '{basicinfo_legend}, artno, titlede, titleen; {category_legend}, category; {description_legend}, shortdescriptionde, shortdescriptionen, descriptionde, descriptionen; {image_legend}, imageSRC; {datasheet_legend}, datasheet_data, dimensions, weight, shippinginfo_de, shippinginfo_en, ean, conradnr, tariffno; {download_legend}, downloadSRC, linkedDownloads; {faq_legend}, faq_data; {recommendedProducts_legend}, recommendedProducts; {youtube_legend}, youtube_de, youtube_en; {datasheetData_legend}, datasheetImageSRC'
      
    ),

      
    // Fields
      
    'fields' => array
      (
        
    'id' => array
        (
          
    'sql'                     => "int(10) unsigned NOT NULL auto_increment"
        
    ),
        
    'tstamp' => array
        (
          
    'label'                     => $GLOBALS['TL_LANG']['tl_products']['tstamp'],
          
    'eval'                    => array('rgxp'=>'date'),
          
    'flag'                    => 5,
          
    'sql'                     => "int(10) unsigned NOT NULL default '0'"
        
    ),
        
    'published' => array
        (
            
    'label'               => $GLOBALS['TL_LANG']['tl_products']['published'],
            
    'filter'              => true,
            
    'inputType'           => 'checkbox',
            
    'sql'                 => "char(1) NOT NULL default '0'"
        
    ),
        
    'artno' => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['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_products']['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_products']['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_products']['category'],
          
    'inputType'               => 'multiColumnWizard',
          
    'eval'                    => array(
            
    'columnFields' => [
              
    'data' => [
                  
    'label'     => &$GLOBALS['TL_LANG']['tl_products']['category']['data'],
                  
    'inputType' => 'select',
                  
    'foreignKey'=> 'tl_categories.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_products']['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_products']['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_products']['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_products']['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_products']['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_products']['sortOrder'],
          
    'sql'                     => "blob NULL"
        
    ),
        
    'downloadSRC' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['downloadSRC'],
          
    'inputType'               => 'fileTree',
          
    'eval'                    => array('multiple'=>true'files'=>true'orderField'=>'orderDownloadSRC''filesOnly'=>true'isGallery'=>false'fieldType'=>'checkbox''path'=>'files/files/Produkte'),
          
    'sql'                     => "blob NULL"
        
    ),
        
    'orderDownloadSRC' => array
        (
          
    'label'                   => &$GLOBALS['TL_LANG']['tl_products']['sortOrder'],
          
    'sql'                     => "blob NULL"
        
    ),
        
    'linkedDownloads' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['linkedDownloads'],
          
    'inputType'               => 'multiColumnWizard',
          
    'eval'                    => array(
            
    'columnFields' => [
              
    'titlede' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['linkedDownloads']['titlede'],
                  
    'inputType' => 'text',
                  
    'mandatory' => true,
                  
    'class'     => 'tl_text',
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%;'],
              ],
              
    'titleen' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['linkedDownloads']['titleen'],
                  
    'inputType' => 'text',
                  
    'mandatory' => true,
                  
    'class'     => 'tl_text',
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%'],
              ],
              
    'data' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['linkedDownloads']['data'],
                  
    'inputType' => 'text',
                  
    'mandatory' => true,
                  
    'class'     => 'tl_text',
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%;'],
              ]
            ],
            
    'style'     => 'max-width:100%;'
          
    ),
          
    'sql'               => "blob NULL"
        
    ),
        
    'datasheet_data' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['datasheet_data'],
          
    'inputType'               => 'multiColumnWizard',
          
    'eval'                    => array(
            
    'columnFields' => [
              
    'headline_de' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['datasheet_data']['headline_de'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'headline_en' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['datasheet_data']['headline_en'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'data_de' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['datasheet_data']['data_de'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'data_en' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['datasheet_data']['data_en'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ]
            ], 
    'style' => 'max-width:100%'
          
    ),
          
    'sql'               => "blob NULL"
        
    ),
        
    'dimensions'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['dimensions'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none'),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'shippinginfo_de'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['shippinginfo_de'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none'),
            
    'sql'                   => "mediumtext NOT NULL default ''"
        
    ),
        
    'shippinginfo_en'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['shippinginfo_en'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none'),
            
    'sql'                   => "mediumtext NOT NULL default ''"
        
    ),
        
    'weight'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['weight'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none'),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'ean'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['ean'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none''doNotCopy'=>true),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'tariffno'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['tariffno'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none'),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'conradnr'                 => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['conradnr'],
            
    'inputType'             => 'textarea',
            
    'eval'                  => array('mandatory'=>false'tl_class'=>'w50''style'=>'resize: none''doNotCopy'=>true),
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'faq_data' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['faq_data'],
          
    'inputType'               => 'multiColumnWizard',
          
    'eval'                    => array(
            
    'columnFields' => [
              
    'questionde' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['faq_data']['questionde'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'questionen' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['faq_data']['questionen'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'answerde' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['faq_data']['answerde'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ],
              
    'answeren' => [
                  
    'label'     => $GLOBALS['TL_LANG']['tl_products']['faq_data']['answeren'],
                  
    'inputType' => 'textarea',
                  
    'mandatory' => true,
                  
    'eval'      => ['mandatory' => false'allowHtml' => false'style' => 'width: 100%; resize: none;'],
              ]
            ],
            
    'style' => 'max-width:100%',
            
    'buttons' => array('copy'=>false)
          ),
          
    'sql'               => "blob NULL"
        
    ),
        
    'recommendedProducts' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['recommendedProducts'],
          
    'inputType'               => 'multiColumnWizard',
          
    'eval'                    => array(
            
    'columnFields' => [
              
    'data' => [
                  
    'label'           => $GLOBALS['TL_LANG']['tl_products']['recommendedProducts']['products'],
                  
    'inputType'       => 'select',
                  
    'foreignKey'      => 'tl_products.artno',
                  
    'eval'            => ['includeBlankOption'=>true'mandatory' => false'allowHtml' => false'style' => 'width: 100%;'],
              ]
            ],
            
    'buttons'               =>  array('copy'=>false),
            
    'tl_class'              =>  'w50'
          
    ),
          
    'sql'                     => "blob NULL"
        
    ),
        
    'youtube_de' => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['youtube_de'],
            
    'inputType'             => 'text',
            
    'eval'                                  => array('mandatory'=>false'tl_class'=>'w50''allowHtml' => false'doNotCopy'=>true),
            
    'search'                => true,
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'youtube_en' => array
        (
            
    'label'                 => $GLOBALS['TL_LANG']['tl_products']['youtube_en'],
            
    'inputType'             => 'text',
            
    'eval'                                  => array('mandatory'=>false'tl_class'=>'w50''allowHtml' => false'doNotCopy'=>true),
            
    'search'                => true,
            
    'sql'                   => "varchar(255) NOT NULL default ''"
        
    ),
        
    'datasheetImageSRC' => array
        (
          
    'label'                   => $GLOBALS['TL_LANG']['tl_products']['datasheetImageSRC'],
          
    'inputType'               => 'fileTree',
          
    'eval'                    => array('mandatory'=>false'multiple'=>false'orderField'=>'orderdatasheetImageSRC''files'=>true'filesOnly'=>true'isGallery'=>true'extensions'=>'png''fieldType'=>'checkbox''path'=>'files/files/Produkte'),
          
    'sql'                     => "blob NULL"
        
    ),
        
    'orderdatasheetImageSRC' => array
        (
          
    'label'                   => &$GLOBALS['TL_LANG']['tl_products']['sortOrderDatasheetImage'],
          
    'sql'                     => "blob NULL"
        
    ),
      )
    );

    class 
    tl_products 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 .= '&amp;id='.$this->Input->get('id').'&amp;tid='.$row['id'].'&amp;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_products'$intId);

        
    // Trigger the save_callback
        
    if (is_array($GLOBALS['TL_DCA']['tl_products']['fields']['published']['save_callback'])) {
            foreach (
    $GLOBALS['TL_DCA']['tl_products']['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_products SET tstamp="time() .", published='" . ($blnPublished '0' '1') . "' WHERE id=?")
            ->
    execute($intId);
        
    $this->createNewVersion('tl_products'$intId);

        
    // Save Log
        
    $product = \BundleProvider\ContaoProductsBundle\Model\ProductModel::findById($intId);
        
    $logMsg BackendUser::getInstance()->username " changed visibility for product " $product->artno " (ID: " $product->id ").";
        \
    System::log($logMsg__METHOD__TL_GENERAL);
      }

      
    // 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.'&amp;id='.$row['id']).'" title="'.Contao\StringUtil::specialchars($title).'"'.$attributes.'>'.Contao\Image::getHtml($icon$label).'</a> ';
        }

      
    // Label Callback
      
    public function label_callback($row$labelDataContainer $dc$args)
      {

        
    // Replace Image
        
    if($args[0]){
          
    $product = \BundleProvider\ContaoProductsBundle\Model\ProductModel::findById($args[0]);

          if(
    $product->orderImageSRC) {
            
    $src = \FilesModel::findByUuid(unserialize($product->orderImageSRC)[0])->path;
            
    $smallImg = \Image::get($src300null'proportional');
            
    $args[0] = '<img src="' $smallImg '" 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);
      }
    }

  4. #4
    Community-Moderator
    Wandelndes Contao-Lexikon
    Avatar von Spooky
    Registriert seit
    12.04.2012.
    Ort
    Scotland
    Beiträge
    34.114
    Partner-ID
    10107

    Standard

    Statt
    PHP-Code:
    'dataContainer' => 'Table' 
    muss es
    PHP-Code:
    'dataContainer' => \Contao\DC_Table::class 
    sein.

    https://docs.contao.org/dev/referenc...fig/#reference
    » sponsor me via GitHub or PayPal or Revolut

  5. #5
    Contao-Nutzer
    Registriert seit
    02.12.2017.
    Beiträge
    140

    Standard

    Das wars, vielen Dank!

Aktive Benutzer

Aktive Benutzer

Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)

Lesezeichen

Lesezeichen

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •