Ankündigung

Einklappen
Keine Ankündigung bisher.

CC Template Variablen: Gruppenausgabe a la CE

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • CC Template Variablen: Gruppenausgabe a la CE

    Warum gibt es eigentlich keine Ausgabe von Gruppen bei CC in den Templates, analog der CEs?

    Wäre für manche Attribute ziemlich hilfreich (Checkboxen...).


  • #2
    Wie meinsten das? Du kannst doch Gruppen nutzen?

    Kommentar


    • #3
      Also das hier funktioniert offenbar nur für CE.

      Wenn ich die Leser-Templates dumpe, sehe ich auch keinerlei Gruppen.

      Kommentar


      • #4
        Die assoziativen Gruppen sind in $this->groups('meineGruppe') (im Leser, sonst über die $entry Schleife gehen)
        http://www.premium-contao-themes.com

        Kommentar


        • #5
          Zitat von Tim Beitrag anzeigen
          Die assoziativen Gruppen sind in $this->groups('meineGruppe') (im Leser, sonst über die $entry Schleife gehen)

          Da kommt nix an...
          weder mit $this->group('meineGruppe') noch mit $this->groups('meineGruppe')

          Bin im Lesermodul.

          Kommentar


          • #6
            Schau dir mal das customcatalog_grouped Template an (ist Bordmittel).
            In CC hat eine "Gruppe" mehr Informationen als in CE.

            Die Abfrage gibt dir einen Array zurück und die Felder sind darin im Schlüssel "fields".

            Code:
            [COLOR=#333333][SIZE=11px][COLOR=#878787]<?php[/COLOR] [COLOR=#0045aa]foreach[/COLOR][COLOR=#000000]([/COLOR][COLOR=#8735a5]$entry[/COLOR][COLOR=#000000]->[/COLOR][COLOR=#3f6e7d]groups[/COLOR]() [COLOR=#000000]as[/COLOR] [COLOR=#8735a5]$group[/COLOR][COLOR=#000000])[/COLOR]: [COLOR=#878787]?>[/COLOR]
            [COLOR=#333333][SIZE=11px][COLOR=#878787]<?php[/COLOR] [COLOR=#0045aa]foreach[/COLOR][COLOR=#000000]([/COLOR][COLOR=#8735a5]$group[/COLOR][[COLOR=#dd2400]'fields'[/COLOR]] [COLOR=#000000]as[/COLOR] [COLOR=#8735a5]$field[/COLOR][COLOR=#000000])[/COLOR]: [COLOR=#878787]?[/COLOR][COLOR=#878787]>[/COLOR]
            [COLOR=#0045aa]<div [/COLOR][COLOR=#007ab7]class=[/COLOR][COLOR=#5d8f00]"[/COLOR][COLOR=#878787]<?php [/COLOR][COLOR=#0045aa]echo[/COLOR][COLOR=#8735a5]$field[/COLOR][COLOR=#000000]->class;[/COLOR][COLOR=#878787]?[/COLOR][COLOR=#878787]>[/COLOR][COLOR=#5d8f00]"[/COLOR][COLOR=#0045aa]>[/COLOR]
            [COLOR=#0045aa]<div [/COLOR][COLOR=#007ab7]class=[/COLOR][COLOR=#5d8f00]"label"[/COLOR][COLOR=#0045aa]>[/COLOR][COLOR=#878787]<?php[/COLOR] [COLOR=#0045aa]echo[/COLOR] [COLOR=#8735a5]$field[/COLOR][COLOR=#000000]->label[/COLOR]; [COLOR=#878787]?[/COLOR][COLOR=#878787]>[/COLOR][COLOR=#0045aa]</div>[/COLOR]
            [COLOR=#0045aa]<div [/COLOR][COLOR=#007ab7]class=[/COLOR][COLOR=#5d8f00]"value"[/COLOR][COLOR=#0045aa]>[/COLOR][COLOR=#878787]<?php[/COLOR] [COLOR=#0045aa]echo[/COLOR] [COLOR=#8735a5]$field[/COLOR][COLOR=#000000]->[/COLOR][COLOR=#3f6e7d]html[/COLOR](); [COLOR=#878787]?[/COLOR][COLOR=#878787]>[/COLOR][COLOR=#0045aa]</div>[/COLOR]
            [COLOR=#0045aa]</div>[/COLOR]
            [COLOR=#878787]<?php[/COLOR] [COLOR=#0045aa]endforeach[/COLOR]; [COLOR=#878787]?>[/COLOR]
            [COLOR=#878787][SIZE=11px]<?php [/SIZE][/COLOR][COLOR=#0045AA][SIZE=11px]endforeach[/SIZE][/COLOR][COLOR=#333333][SIZE=11px]; [/SIZE][/COLOR][COLOR=#878787][SIZE=11px]?[/SIZE][/COLOR][COLOR=#878787][SIZE=11px]>[/SIZE][/COLOR][/SIZE][/COLOR][/SIZE][/COLOR]
            http://www.premium-contao-themes.com

            Kommentar


            • #7
              Ok, das gibt komplett alle Gruppen und alle Felder aus.
              Ich möchte aber nur eine einzelne Gruppe mit allen Feldern bekommen. Wie geht dies?

              Kommentar


              • #8
                Assoziativ auf ->group(). Feld-Attribute liegen im array/variable "fields"

                Code:
                <?php foreach($entry->group('MEIN_GRUPPEN_ALIAS')->fields as $field): ?>
                <div class="label"><?php echo $field->label; ?></div>
                <div class="value"><?php echo $field->html(); ?></div>
                <?php endforeach; ?>
                Die ->get() Methode erlaubt ebenfalls Zugriff auf Objektbasierte Variablen

                Code:
                var_dump( $entry->group('MEIN_GRUPPEN_ALIAS')->get('fields') );
                (Im Leser geht auch $this)
                http://www.premium-contao-themes.com

                Kommentar


                • #9
                  Also im Leser bin ich nun hiermit weitergekommen. Mit der einleitenden Schleife passt nun alles wie gewünscht:

                  Code:
                  <?php foreach($this->entries as $entry): ?>
                  <?php foreach($entry->group('gruppenname‘)->fields as $field): ?>
                  <div class="label"><?php echo $field->label; ?></div>
                  <div class="value"><?php echo $field->html(); ?></div>
                  <?php endforeach; ?>
                  <?php endforeach; ?>

                  (Im Leser geht auch $this)
                  Das funktioniert analog nicht. var_dump wie oben beschrieben mit $this ergibt einen Fehler, var_dump auf group alleine ergibt NULL.
                  Zuletzt geändert von eblick; 08.07.2020, 07:12.

                  Kommentar


                  • #10
                    Check noch schnell, dass du kein Tiefkomma nutzt, sondern zwei Hochkomma.
                    http://www.premium-contao-themes.com

                    Kommentar


                    • #11
                      Ja, immer Hochkomma, hats beim Copy&Paste hier umgewandelt...

                      edit: habs oben geändert, falls es jemand abschaut

                      Kommentar

                      Lädt...
                      X