vendor/contao-themes-net/theme-components-bundle/src/Element/TeaserBoxElement.php line 39

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * theme components bundle for Contao Open Source CMS
  5.  *
  6.  * Copyright (C) 2022 pdir / digital agentur <develop@pdir.de>
  7.  *
  8.  * @package    contao-themes-net/theme-components-bundle
  9.  * @link       https://github.com/contao-themes-net/theme-components-bundle
  10.  * @license    LGPL-3.0+
  11.  * @author     pdir GmbH <develop@pdir.de>
  12.  *
  13.  * For the full copyright and license information, please view the LICENSE
  14.  * file that was distributed with this source code.
  15.  */
  16. namespace ContaoThemesNet\ThemeComponentsBundle\Element;
  17. use Contao\ContentElement;
  18. use Contao\FilesModel;
  19. use Contao\System;
  20. class TeaserBoxElement extends ContentElement
  21. {
  22.     use ElementHelperTrait;
  23.     /**
  24.      * Template.
  25.      *
  26.      * @var string
  27.      */
  28.     protected $strTemplate 'ce_cthemes_teaserbox';
  29.     /**
  30.      * Generate the content element.
  31.      */
  32.     protected function compile(): void
  33.     {
  34.         $this->Template->page $this->ct_teaserBox_page;
  35.         $this->Template->pageText $this->ct_teaserBox_pageText;
  36.         $this->Template->pageTitle '';
  37.         $this->Template->target '';
  38.         $this->Template->rel '';
  39.         // Overwrite template
  40.         if ('' !== $this->ct_teaserBox_customTpl) {
  41.             $this->Template->setName($this->ct_teaserBox_customTpl);
  42.         }
  43.         // Add an image
  44.         if ($this->addImage && '' !== $this->singleSRC) {
  45.             $objModel FilesModel::findByUuid($this->singleSRC);
  46.             if (null !== $objModel && is_file(System::getContainer()->getParameter('kernel.project_dir').'/'.$objModel->path)) {
  47.                 $this->singleSRC $objModel->path;
  48.                 $this->Template->picture $objModel->path;
  49.                 $this->addImageToTemplate($this->Template$this->arrDatanullnull$objModel);
  50.             }
  51.         }
  52.         // Overwrite link target
  53.         if ($this->target) {
  54.             $this->Template->target ' target="_blank"';
  55.             $this->Template->rel ' rel="noreferrer noopener"';
  56.         }
  57.         // Overwrite link title
  58.         if ('' !== $this->ct_teaserBox_pageTitle) {
  59.             $this->Template->pageTitle ' title="'.$this->ct_teaserBox_pageTitle.'"';
  60.         }
  61.     }
  62. }