Ergebnis 1 bis 7 von 7

Thema: Fehler beim Nichtausfüllen eines RSCE

  1. #1
    Contao-Nutzer
    Registriert seit
    25.09.2010.
    Ort
    Dortmund
    Beiträge
    196

    Standard Fehler beim Nichtausfüllen eines RSCE

    Hallo,

    ich habe ein merkwürdiges Verhalten bei einem RSCE.
    Vorab, das Inhaltselement funktioniert einwandfrei, wenn ich alle Felder ausfülle.

    Wenn ich allerdings das Element wähle und nichts ausfülle, sondern über den Zurück-Link wieder zur Übersicht gehe, erhalte ich eine Fehlermeldung im Browser.

    PHP-Code:
    An exception has been thrown during the rendering of a template ("Contao\CoreBundle\Twig\Runtime\FigureRuntime::buildFigure(): Argument #1 ($from) must be of type Contao\FilesModel|Contao\Image\ImageInterface|string|int, null given, called in /.../var/cache/prod/twig/21/21bf61f705996038be3373b14e7797d8.php on line 95"). 
    Ich kann die Inhaltselemente dieser Seite anschließend nicht mehr bearbeiten, im Log steht:

    PHP-Code:
    [2024-09-16T10:58:15.899440+02:00request.INFOMatched route "contao_backend". {"route":"contao_backend","route_parameters":{"_route":"contao_backend","_scope":"backend","_controller":"Contao\\CoreBundle\\Controller\\BackendController::mainAction"},"request_uri":"https://domain.de/contao?do=article&id=5&ref=nLNpvI2Z&rt=a319e2b978c58eb.jtn9aRACg0ZxfFHP3iJexmwo7zGFZizsrpkxXw2HWX8.3ei-BVpF2zc6GhW_lhEIilpplUHOFlykyt9uMm7uAUvMsMU_IETZFUYwBA&table=tl_content","method":"GET"} {"request_uri":"https://domain.de/contao?do=article&id=5&ref=nLNpvI2Z&rt=a319e2b978c58eb.jtn9aRACg0ZxfFHP3iJexmwo7zGFZizsrpkxXw2HWX8.3ei-BVpF2zc6GhW_lhEIilpplUHOFlykyt9uMm7uAUvMsMU_IETZFUYwBA&table=tl_content","request_method":"GET"}
    [
    2024-09-16T10:58:15.978945+02:00request.CRITICALUncaught PHP Exception Twig\Error\RuntimeError"An exception has been thrown during the rendering of a template ("Contao\CoreBundle\Twig\Runtime\FigureRuntime::buildFigure(): Argument #1 ($from) must be of type Contao\FilesModel|Contao\Image\ImageInterface|string|int, null given, called in /home2/www/daikunlab/_md/.../var/cache/prod/twig/21/21bf61f705996038be3373b14e7797d8.php on line 95")." at rsce_img-text-box.html.twig line 14 {"exception":"[object] (Twig\\Error\\RuntimeError(code: 0): An exception has been thrown during the rendering of a template (\"Contao\\CoreBundle\\Twig\\Runtime\\FigureRuntime::buildFigure(): Argument #1 ($from) must be of type Contao\\FilesModel|Contao\\Image\\ImageInterface|string|int, null given, called in /home2/www/daikunlab/_md/.../var/cache/prod/twig/21/21bf61f705996038be3373b14e7797d8.php on line 95\"). at /home2/www/daikunlab/_md/.../templates/rsce_img-text-box.html.twig:14)\n[previous exception] [object] (TypeError(code: 0): Contao\\CoreBundle\\Twig\\Runtime\\FigureRuntime::buildFigure(): Argument #1 ($from) must be of type Contao\\FilesModel|Contao\\Image\\ImageInterface|string|int, null given, called in /home2/www/daikunlab/_md/.../var/cache/prod/twig/21/21bf61f705996038be3373b14e7797d8.php on line 95 at /home2/www/daikunlab/_md/.../vendor/contao/core-bundle/src/Twig/Runtime/FigureRuntime.php:63)"} {"request_uri":"https://domain.de/contao?do=article&id=5&ref=nLNpvI2Z&rt=a319e2b978c58eb.jtn9aRACg0ZxfFHP3iJexmwo7zGFZizsrpkxXw2HWX8.3ei-BVpF2zc6GhW_lhEIilpplUHOFlykyt9uMm7uAUvMsMU_IETZFUYwBA&table=tl_content","request_method":"GET"}
    [2024-09-16T10:58:16.002235+02:00messenger.INFOStopping worker. {"transport_names":["contao_prio_high"]} {"request_uri":"https://domain.de/contao?do=article&id=5&ref=nLNpvI2Z&rt=a319e2b978c58eb.jtn9aRACg0ZxfFHP3iJexmwo7zGFZizsrpkxXw2HWX8.3ei-BVpF2zc6GhW_lhEIilpplUHOFlykyt9uMm7uAUvMsMU_IETZFUYwBA&table=tl_content","request_method":"GET"
    Folgende Zeile in meinem RSCE ist vermutlich dafür verantwortlich (eine Bildgröße für 1 ist definiert):

    PHP-Code:
    <div class="ce-textimage-box--img" style="background-image:url({{ figure(image,1).image.img.src }})"></div
    Wenn ich diese Zeile lösche kann ich das Inhaltselement wieder bearbeiten.

    Wo kann da der Fehler liegen?


    Gruß Michael

    Contao 5.3.14

  2. #2
    Alter Contao-Hase
    Registriert seit
    24.02.2021.
    Beiträge
    1.490
    Partner-ID
    11715
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Poste auch bitte deine RSCE config

  3. #3
    Contao-Nutzer
    Registriert seit
    25.09.2010.
    Ort
    Dortmund
    Beiträge
    196

    Standard

    Zitat Zitat von zoglo Beitrag anzeigen
    Poste auch bitte deine RSCE config
    Ich habe jetzt alles drin gelassen...

    PHP-Code:
    <?php

    return array(
        
    'label' => array('Box: Text + Bild''Text und Bild in einer Box'),
        
    'types' => array('content'),
        
    'contentCategory' => 'texts',
        
    'fields' => array(
            
    'contentsize' => array(
                
    'label' => array('Angabe der Breite für den Inhalt''Legen Sie die Inhaltsbreite fest'),
                
    'inputType' => 'radio',
                
    'default' => 'maxwide',
                
    'options' => array(
                    
    'maxwide' => 'Kompletter Inhaltsbereich (entspricht 100% der Breite des Browsers)',
                    
    'defaultwide' => 'Normaler Inhaltsbereich (entspricht 100% der Webseitenbreite)',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                ),
            ),
            
    'position' => array(
                
    'label' => array('Position Text/Bild''Wählen Sie die Positionen für Text und Bild'),
                
    'inputType' => 'radio',
                
    'default' => 'textimg',
                
    'options' => array(
                    
    'textimg' => 'Text | Bild',
                    
    'imgtext' => 'Bild | Text',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                ),
            ),
            
    'description1' => array(
                
    'label' => array('Bild + Hintergrundfarbe'''),
                
    'inputType' => 'group',
            ),
            
    'image' => array(
                
    'label' => array('Bild''Bild auswählen'),
                
    'inputType' => 'fileTree',
                
    'eval' => array(
                    
    'fieldType' => 'radio',
                    
    'filesOnly' => true,
                    
    'extensions' => '%contao.image.valid_extensions%',
                    
    'tl_class' => 'w50',
                    
    'mandatory' => true,
                ),
            ),
            
    'imgposition' => array(
                
    'label' => array('Bildausrichtung''Wählen Sie die Bildausrichtung'),
                
    'inputType' => 'radio',
                
    'options' => array(
                    
    'imgleft' => 'Bild links ausrichten',
                    
    'imgcenter' => 'Bild mittig ausrichten',
                    
    'imgright' => 'Bild rechts ausrichten',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                    
    'mandatory' => true,
                ),
            ),
            
    'backgroundcolor' => array(
                
    'label' => array('Hintergrundfarbe''Wählen Sie eine Hintergrundfarbe'),
                
    'inputType' => 'select',
                
    'default' => 'nocolor',
                
    'options' => array(
                    
    'nocolor' => 'Keine Farbe',
                    
    'lightgrey' => 'Helles Grau',
                    
    'mediumgrey' => 'Mittleres Grau',
                    
    'darkgrey' => 'Dunkles Grau',
                    
    'pagecolor' => 'Passende Seitenfarbe',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'clr',
                    
    'mandatory' => true,
                ),
            ),
            
    'description2' => array(
                
    'label' => array('Text'''),
                
    'inputType' => 'group',
            ),
            
    'headline' => array(
                
    'label' => array('Überschrift''Geben Sie eine Überschrift ein.'),
                
    'inputType' => 'text',
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                    
    'mandatory' => true,
                ),
            ),
            
    'headlinesize' => array(
                
    'label' => array('Größe''Wählen Sie die Größe für die Überschrift'),
                
    'inputType' => 'select',
                
    'options' => array(
                    
    'h2' => 'Größe 2',
                    
    'h3' => 'Größe 3',
                    
    'h4' => 'Größe 4',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w25',
                    
    'mandatory' => true,
                ),
            ),
            
    'text' => array(
                
    'label' => array('Text''Geben Sie einen Text ein'),
                
    'inputType' => 'textarea',
                
    'eval' => array(
                    
    'rte' => 'tinyMCE',
                    
    'tl_class' => 'clr',
                    
    'mandatory' => true,
                ),
            ),
            
    'description3' => array(
                
    'label' => array('Link einfügen'''),
                
    'inputType' => 'group',
            ),
            
    'link' => array(
                
    'label' => array('Link zur Seite''Wählen Sie die Seite, zu der verlinkt werden soll'),
                
    'inputType' => 'url',
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                    
    'fieldType' => 'radio',
                ),
            ),
            
    'linktext' => array(
                
    'label' => array('Linktext''Text, der auf dem Linkbutton stehen soll'),
                
    'inputType' => 'text',
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                ),
            ),
            
    'buttoncolor' => array(
                
    'label' => array('Farbe Linkbutton''Wählen Sie die Farbe für den Linkbutton'),
                
    'inputType' => 'radio',
                
    'default' => 'nocolor',
                
    'options' => array(
                    
    'nocolor' => 'Keine Farbe',
                    
    'lightgrey' => 'Helles Grau',
                    
    'mediumgrey' => 'Mittleres Grau',
                    
    'darkgrey' => 'Dunkles Grau',
                    
    'pagecolor' => 'Passende Seitenfarbe',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                ),
            ),
            
    'description4' => array(
                
    'label' => array('Geben Sie die Innenabstände für oben und unten ein'''),
                
    'inputType' => 'group',
            ),
            
    'paddingtop' => array(
                
    'label' => array('Innenabstand oben''Geben Sie den Innenabstand für oben ein'),
                
    'inputType' => 'radio',
                
    'default' => 'pt-0',
                
    'options' => array(
                    
    'pt-0' => 'Keinen Innenabstand oben',
                    
    'pt-s' => 'Innenabstand oben - S',
                    
    'pt-m' => 'Innenabstand oben - M',
                    
    'pt-l' => 'Innenabstand oben - L',
                    
    'pt-xl' => 'Innenabstand oben - XL',
                    
    'pt-xxl' => 'Innenabstand oben - XXL',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                    
    'mandatory' => true,
                ),
            ),
            
    'paddingbottom' => array(
                
    'label' => array('Innenabstand unten''Geben Sie den Innenabstand für unten ein'),
                
    'inputType' => 'radio',
                
    'default' => 'pb-0',
                
    'options' => array(
                    
    'pb-0' => 'Keinen Innenabstand unten',
                    
    'pb-s' => 'Innenabstand unten - S',
                    
    'pb-m' => 'Innenabstand unten - M',
                    
    'pb-l' => 'Innenabstand unten - L',
                    
    'pb-xl' => 'Innenabstand unten - XL',
                    
    'pb-xxl' => 'Innenabstand unten - XXL',
                ),
                
    'eval' => array(
                    
    'tl_class' => 'w50',
                    
    'mandatory' => true,
                ),
            ),
        ),           
    );
    PHP-Code:
    <div class="{{ contentsize }}">
        <
    div class="ce-textimage-box {{ position }}">
            <
    div class="ce-textimage-box--text {{ backgroundcolor }} {{ paddingtop }} {{ paddingbottom }}">
                <
    div class="ce-textimage-box--text--inside">
                    <{{ 
    headlinesize }}>{{ headline }}</{{ headlinesize }}>
                    {{ 
    text|raw }}
                    {% if 
    link %}
                    <
    div class="content-hyperlink content-hyperlink-extra button-s">
                        <
    a href="{{ link }}" class="{{ buttoncolor }}" title="{{ linktext }}">{{ linktext }}</a>
                    </
    div>
                    {% endif %}
                </
    div>
            </
    div>
            <
    div class="ce-textimage-box--img {{ imgposition }}" style="background-image:url({{ figure(image,1).image.img.src }})"></div>     
        </
    div>
    </
    div

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

    Standard

    Zitat Zitat von scroll Beitrag anzeigen
    Wo kann da der Fehler liegen?
    Du musst in deinem Template prüfen, ob die Variable "image" überhaupt befüllt ist, befor du {{ figure }} ausführst.
    » sponsor me via GitHub or Revolut

  5. #5
    Contao-Nutzer
    Registriert seit
    25.09.2010.
    Ort
    Dortmund
    Beiträge
    196

    Standard

    Zitat Zitat von Spooky Beitrag anzeigen
    Du musst in deinem Template prüfen, ob die Variable "image" überhaupt befüllt ist, befor du {{ figure }} ausführst.
    PHP-Code:
    <div class="ce-textimage-box--img {{ imgposition }}"{% if image is defined %} style="background-image:url({{ figure(image,1).image.img.src }})"{% endif %}></div
    Das funktioniert, gibt es da Einwände?

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

    Standard

    Nein, kannst du so lassen. Alternativ kannst du auch {% if image|default %} schreiben (wäre etwas kürzer).
    » sponsor me via GitHub or Revolut

  7. #7
    Contao-Fan Avatar von Kopfnuss
    Registriert seit
    05.09.2012.
    Ort
    Zwickau
    Beiträge
    348
    Partner-ID
    11375
    Contao-Projekt unterstützen

    Support Contao

    Standard

    Ich nutze für Felder, die leer sein können und nicht dürfen, immer den
    Code:
    default
    Filter.
    https://twig.symfony.com/doc/3.x/filters/default.html

Aktive Benutzer

Aktive Benutzer

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

Berechtigungen

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