We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5282
    • 147 Posts
    Hello ! Voilà je viens de faire un petit snippet sympa, qui permet d’afficher du texte dans des "boîtes" colorées et aux coins arrondis, tout ca sans images !!
    ( adapté d’un plug-in pour dokuwiki, lui-même basé sur la méthode "snazzy borders" de stu nicholls, elle-même inspirée de la méthode "nifty corners" d’Alessandro Fulciniti .)

    exemples ici

    Version 1.0

    copiez ca dans l’un de vos fichiers CSS
    /* SNAZZY BORDERS & ROUNDED BOXES */
    /* You can add classes, change colors tu suit your needs :) */
    /* Modx Roundboxes snippet by Vinh CHUC, [email protected] */
    div.box {
      width: 50%;
      margin: 1em auto;
      border: 1px solid;
      padding: 4px;
    }
     
    /* rounded corners styles from Stu Nicholls snazzy borders, http://www.cssplay.co.uk/boxes/snazzy.html */
    .xtop, .xbottom {background:transparent; font-size:0; line-height: 1px;}
    .xb1, .xb2, .xb3, .xb4 {display:block; overflow:hidden; border-style: solid;}
    .xb2, .xb3 {height:1px;}
    .xb2, .xb3, .xb4 {border-width:0 1px;}
    .xb1 {height: 0; margin:0 5px; border-width:1px 0 0 0;}
    .xb2 {margin:0 3px; border-width:0 2px;}
    .xb3 {margin:0 2px;}
    .xb4 {height:2px; margin:0 1px;}
     
    div.box .xtop, div.box .xbottom {display: none;}
    div.box.round .xtop, div.box.round .xbottom {display: block;}
     
    div.box.round { border: none; padding: 0;}
    div.box.round .xbox {display:block; border-width:0 1px; border-style: solid; padding: 0 4px; }
     
    div.box p.box_title, div.box p.box_caption {
      font-size: 90%;
      margin: 0;
      padding: 2px 6px;
      line-height: 1.2em;
    }
     
    div.box p.box_title { margin-bottom: 4px;}
    div.box p.box_caption { margin-top: 4px;}
     
    div.box .box_content {
      margin: 0;
      padding: 0 6px;
      border-width: 1px;
      border-style: dashed;
      line-height: 1.2em;
    }
     
    /* floating alignment */
     
    div.box.left {
      float: left;
      margin-right: 1em;
    }
     
    div.box.right {
      float: right;
      margin-left: 1em;
    }
     
    /* colours */
    /* default */
    div.box, div.box .box_content, div.box .xbox, div.box .xb1, div.box .xb2, div.box .xb3, div.box .xb4 {
      border-color:  #8cacbb;
    }
     
    div.box, div.box .xbox, div.box .xb1, div.box .xb2, div.box .xb3, div.box .xb4 {
      background: #ecf1f4;
    }
     
    div.box p.box_title, div.box p.box_caption { background: #dee7ec;}
    div.box .box_content { background: #f7fafb;}
     
    /* blue */
    div.box.blue, div.box.blue .box_content, div.box.blue .xbox, 
    div.box.blue .xb1, div.box.blue .xb2, div.box.blue .xb3, div.box.blue .xb4 {
      border-color:  #bbbbdd;
    }
     
    div.box.blue, div.box.blue .xbox, 
    div.box.blue .xb1, div.box.blue .xb2, div.box.blue .xb3, div.box.blue .xb4 {
      background: #e4ecf8;
    }
     
    div.box.blue p.box_title, div.box.blue p.box_caption {background: #cad0ee;}
    div.box.blue .box_content {background: #f4f8fd;}
     
    /* red */
    div.box.red, div.box.red .box_content, div.box.red .xbox, 
    div.box.red .xb1, div.box.red .xb2, div.box.red .xb3, div.box.red .xb4 {
      border-color:  #ddbbbb;
    }
     
    div.box.red, div.box.red .xbox, 
    div.box.red .xb1, div.box.red .xb2, div.box.red .xb3, div.box.red .xb4 {
      background: #f8ece4;
    }
     
    div.box.red p.box_title, div.box.red p.box_caption {background: #eed0ca;}
    div.box.red .box_content {background: #fdf4ec;}
     
    /* green */
    div.box.green, div.box.green .box_content, div.box.green .xbox, 
    div.box.green .xb1, div.box.green .xb2, div.box.green .xb3, div.box.green .xb4 {
      border-color:  #bbddbb;
    }
     
    div.box.green, div.box.green .xbox, 
    div.box.green .xb1, div.box.green .xb2, div.box.green .xb3, div.box.green .xb4 {
      background: #e4f8f2;
    }
     
    div.box.green p.box_title, div.box.green p.box_caption {background: #c4e4d4;}
    div.box.green .box_content {background: #ecfaf6;}
     
    /* orange */
    div.box.orange, div.box.orange .box_content, div.box.orange .xbox, 
    div.box.orange .xb1, div.box.orange .xb2, div.box.orange .xb3, div.box.orange .xb4 {
      border-color:  #da3;
    }
     
    div.box.orange, div.box.orange .xbox, 
    div.box.orange .xb1, div.box.orange .xb2, div.box.orange .xb3, div.box.orange .xb4 {
      background: #f4e8ca;
    }
     
    div.box.orange p.box_title, div.box.orange p.box_caption {background: #f0d499;}
    div.box.orange .box_content {background: #f8f0da;}
     
    /* must come last to override coloured background when using rounded corners */
     
    div.box.round {
      background: transparent !important;
    }
     
    /* end plugin:box */
    


    le snippet

    // This plug-in generates Round Boxes without images, just pure CSS. Adapted from a dokuwiki plug-in, 
    // itself based on a css technique "snazzy borders" : http://www.cssplay.co.uk/boxes/snazzy.html" by stu 
    // nicholls, itself based on the "nifty corners" technique http://pro.html.it/esempio/nifty/  by Alessandro // Fulciniti.
    // Examples here http://wiki.jalakai.co.uk/dokuwiki/doku.php/test/boxes
    // Syntax : 
    //[[Roundboxes? &title=yourtitle&content=yourcontent&round=yes or no&width=width in %&color=a //color&align=left or right]]   
    // you are not forced to set all the variables, only title and content are really necessary, others have 
    // default values
    // example :
    //[[Roundboxes? &title=luke&content=I'm your father&color=green&width=80&round=yes&align=right]]
    // Version 1.0 24/12/2005
    
    //Parameters
    
      // The Width of the box in percent, default is 80% 
    if ( $width == NULL )
    { $width = '80' ;}
    
     // Round or not round corners ? Default is yes, enter no to disable round corners
    if ( $round == "no" )
    { $round = NULL; }
    else { $round ='round'; }
    
     // The Color of the Boxes, default color is blue, ( blue, red, green, orange )
    if ( $color == NULL )
    { $color = 'blue'; }
    
     // the $align variable can be set to left or right, your boxe will then have a float:left/tight property
    
    
    // The Core of the Snippet :)
    $s = ' ';
    
    $var1 ='<div class="box ';
    $var2 ='" style="width:';
    $var3 ='%;">
     <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
     <div class="xbox">
    <p class="box_title">';
    $var4 ='</p>
    <div class="box_content"><p>';
    $var5 ='</p></div>
     </div>
     <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
    </div>';
    
    $output = $var1.$align.$s.$color.$s.$round.$var2.$width.$var3.$title.$var4.$content.$var5;
    
    echo $output;
    
    // Plug-in made by Vinh CHUC, [email protected]
    
    


    utilisation :
    [!Roundboxes? &title=votretitre&content=lecontenu!]
    vous pouvez également mettre les variables pour les couleurs, ou créer plusieurs versions du snippet pour chacune des couleurs ....
    n.b. je suis un grand débutant en php, si vous avez des suggestions vs êtes le(a) bienvenu(e)



      i’m not a native english speaker, sorry if there are any mistakes ! smiley

      Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
      • 18219
      • 826 Posts
      Oui, en effet, tu peux améliorer le code, notamment en faisant passer plus de données en paramètres :

      // $title : Titre de la box
      // $color : Couleur souhaitée
      // $form : Forme des angles souhaités
      // $width : Largeur
      // $content : Contenu
      
      $output = '<div class="box ';
      $output = .$color;
      $output = .s;
      $output = .$form;
      $output = .s;
      $output = .'" style="width:';
      $output = .$width;
      $output = .'%;">
       <b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
       <div class="xbox">
      <p class="box_title">';
      $var4 ='</p>
      <div class="box_content"><p>';
      $output = .$title;
      $output = .'</p>
      <div class="box_content"><p>';
      $output = .$content;
      $output = .'</p></div>
       </div>
       <b class="xbottom"><b class="xb4"></b><b class="xb3"></b><b class="xb2"></b><b class="xb1"></b></b>
      </div>';
      
      echo $output;
      


      utilisation :
      [!Roundboxes? &title=votretitre&content=lecontenu$color=votrecouleur$width=votrelargeur$form=votreforme!]

      Je n’ai pas testé le code. Il reste simple et peut-être amélioré encore. Mais il a l’avantage d’être unique pour toute l’application.

      Il faudrais lui rajouter des instructions pour vérifier que les paramètres sont renseignés sinon mettre des valeurs par défaut wink
        Marc
        I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
        • 32241
        • 1,495 Posts
        I’m sorry if I don’t speak french. As I understand from the code, it’s able to generate a roundbox, right? This might be a usable simple snippet that we can use over and over while buildsing simple template. Hope I get it right.
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 5282
          • 147 Posts
          yes it generates round boxes ( without any image ) ,
          example here http://wiki.jalakai.co.uk/dokuwiki/doku.php/test/boxes
          juste paste the css code in your css, and add the snippet of course smiley ( i’m a php noob, so the snippet can be improved ( e.g. there isn’t default values for variables ))

          //

          a vrai dire je ne connais quasiment pas le php, j’ai lu vite fait quelques cours sur le site du zero, mais pas plus d’un heure en tout smiley, ( surtout le chapitre sur les concaténation de variables )
          sinon comment on fait pour définir des variables par défaut ?? si on les déclare au début du code, les variables getpost ont la priorité sur celles-ci ??

          merci beaucoup
            i’m not a native english speaker, sorry if there are any mistakes ! smiley

            Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
            • 32241
            • 1,495 Posts
            Thanks for clarifying it.
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
              • 18219
              • 826 Posts
              Bonjour chucky,

              Non, les varaibles passés en paramétre ne sont pa prioritaire. C’est plutôt l’inverse.
              Il faut tester la variable avec l’instruction if et la condition isnull par exemple.
              Si elle est nulle tu lui affecte une valeur sinon tu garde sa valeur.
              Je suis absent tt la journée. Je ne peux t’aider d’avantage aujourd’hui
                Marc
                I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
                • 5282
                • 147 Posts
                ben si vous pouviez me donner vite fait la syntaxe générique pour tester si une variable est "nulle" et qu’en suite on lui affecte une valeur ca serait cool wink ( peut-être y-a-t-il un snippet déjà intégré à modx qui soit suffisamment clair pour que je m’en inspire ? )

                merci
                  i’m not a native english speaker, sorry if there are any mistakes ! smiley

                  Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )
                  • 1876
                  • 835 Posts
                  Salut

                  Tu peux regarder du coté de isset

                  Aour
                    • 18219
                    • 826 Posts
                    if (!isset($var)){$var="toto";}
                    


                      Marc
                      I&#39;m French... Sorry for my bad English, I use &#39; Google Translator&#39; or other... but that remains that tools wink
                      • 5282
                      • 147 Posts
                      merci ! mais à quoi sert le point d’exclamation en face de isset ??
                        i’m not a native english speaker, sorry if there are any mistakes ! smiley

                        Pikkitux.com Website about Ubuntu Linux, Website Creation, and many other how-tos, tips and tricks ... ( French Language, and of course Modx Powered ! )