Ankündigung

Einklappen
Keine Ankündigung bisher.

Select Multiple attribute SQL varchar(64)

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

  • Select Multiple attribute SQL varchar(64)

    Hello,

    I have a Select Multiple attribute which has 8 options. It works fine as long as only 3 options are checked. When checking more than 3 options, everything is erased.

    I have been searching for the cause, and found that Select Multiple creates a varchar(64) field in the SQL database which seems to small to hold the data. When I change this in phpMyadmin to varchar(255) the problem is solved, and i can check all 8 options.

    You could say 'problem solved' But when I do a database update in Contao Extensions manager, Contao wants to change the field in the sql back to varchar(64) which would result in losing all entries in that field. That is no problem today or tomorrow, because there is only 1 field Contao want to change. But When I add an extention let's say next year, the chances are real that by then I will forget to uncheck that field in the Contao Update database, resulting in a large amount of data lost.

    Is there a way I can tell Contao not to update that field ever. Or, even better, change the default for a Select Multiple attribute to varchar(255) ?

    Thanks for your help.

  • #2
    Jup, you must use a Tags attribute or selectdb für multiple choice fields.
    It's on my update plan to remove the checkbox in the backend. It's distracting for selects. Before doing this I will give it a try to allow the multiple choice and pass a longer column type.

    Is there a way I can tell Contao not to update that field ever. Or, even better, change the default for a Select Multiple attribute to varchar(255) ?
    It should be blob. Yes, you can use the dacconfig.php file for doing this.
    Zuletzt geändert von Tim; 02.03.2016, 07:18.
    http://www.premium-contao-themes.com

    Kommentar


    • #3
      It's on my update plan to support multiple values in CC here. Later in CE as well.
      Zuletzt geändert von Tim; 02.03.2016, 07:42.
      http://www.premium-contao-themes.com

      Kommentar


      • #4
        Hi Tim,

        Thanks for the explanation. I will change the Select Multiple to a Tags attribute. I did a test in a local hosted version of the site, and this approach has the aditional benefit that I can use this tags attribute as source for the variants in the Notelist, so people only can check the variants of a product that are actual available.
        I only have to see how these tags will be formatted on the Notelist e-mail. Maybe I will be back later to fine-tune this.

        Kommentar


        • #5
          Hi Tim,

          As I feared... everything works perfect, exept for the e-mail output. I get only this in the mail: (Array)
          instead of the variant checked in the notelist before sending.

          Can you please use your PHP magic in the mail_notelist_customelenments.html5 template to get this right?

          See attached screenshots.
          Angehängte Dateien

          Kommentar


          • #6
            Yes. You must deserialize the value and print the array as string. that the way it is. that's live of a developer
            http://www.premium-contao-themes.com

            Kommentar


            • #7
              Hi Tim, thanks, but... as mentioned in other posts last week, I'm not a developper, I'm a photographer and graphic designer... that's the reason why I prefer Contao over WP, in contao I can make (almost) anything without PHP knowledge.
              Could you please be so kind and help me with the PHP code?
              I understand that your time is valuable, but I am happy to pay you for the time you would spend on this.

              Kommentar


              • #8
                Well, become a part of both sides

                mail_notelist_customelements.html5

                PHP-Code:
                <?php
                /**
                 * Template for customelements notelist email output
                 */
                ?>


                <?php if(count($this->entries) > 0): ?>
                <?php 
                foreach($this->entries as $entry): ?>
                <?php 
                echo $entry['amount']; ?>x
                <?php foreach($entry['fields'] as $field):?>
                <?php 
                echo $field->value(); ?>
                <?php 
                endforeach; ?>
                <?php 
                if(count($entry['variants']) > 0): ?>

                (<?php foreach($entry['variants'] as $name => $data): ?>
                <?php 
                if($data['value']): ?>

                <?php // convert array values to comma separated string
                if(is_array($data['value']))
                {
                    
                $data['value'] = implode(', '$data['value']);
                }
                ?>

                <?php echo $data['value']; ?>
                <?php 
                endif; ?>
                <?php 
                endforeach; ?>)
                <?php endif; ?>

                <?php endforeach; ?>
                <?php 
                else: ?>
                <?php 
                echo $this->empty?>
                <?php 
                endif; ?>
                http://www.premium-contao-themes.com

                Kommentar


                • #9
                  Hi Tim, Thanks for the template. It is working.
                  Only 1 problem left... I get the ID of the tag instead of the name.

                  Kommentar


                  • #10
                    Zitat von Willy Beitrag anzeigen
                    Hi Tim, Thanks for the template. It is working.
                    Only 1 problem left... I get the ID of the tag instead of the name.

                    That should do the trick:

                    PHP-Code:
                    <?php // convert array values to comma separated string
                    if(is_array($data['value']))
                    {
                        
                    $objTags = \Database::getInstance()->execute("SELECT * FROM tl_pct_customelement_tags WHERE id IN(".implode(','$data['value']).")");
                        
                    $data['value'] = implode(', '$objTags->fetchEach('title'));
                    }
                    ?>
                    http://www.premium-contao-themes.com

                    Kommentar


                    • #11
                      Hello Tim, almost perfect! I barely dare to ask, but is there also a way to delete () and extra space ?


                      1x ABRIKOOS ROYAL

                      Fruitbomen


                      (


                      Halfstam)

                      Kommentar


                      • #12
                        Zitat von Willy Beitrag anzeigen
                        Hello Tim, almost perfect! I barely dare to ask, but is there also a way to delete () and extra space ?


                        1x ABRIKOOS ROYAL

                        Fruitbomen


                        (


                        Halfstam)

                        Rewrite the template to single lines. Any whitespace, tabs, enters will be recognized in the mail and printed just as it is in the template. Kind of like a "what you see is what you get" here
                        http://www.premium-contao-themes.com

                        Kommentar


                        • #13
                          O.K. Tim,

                          Thanks for your time and patience.

                          Kommentar

                          Lädt...
                          X