We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Customize grid with text fields

How Do I?

Andrés Molina's avatar
Andrés Molina
43 posts
5 years ago
Andrés Molina's avatar Andrés Molina

You need ganon.php https://code.google.com/archive/p/ganon/ its a DOM parser

and then create a custom addon(Plugin) with the function

for example, in need a text field for URL and select field for “url type” selector(url, twitter, facebook, etc)

My function on custom Plugin

public function getGridValues(){
  require dirname(__FILE__).'/lib/ganon.php';
  $html = str_get_dom(ee()->TMPL->tagdata);
  $data="";
  foreach($html('tbody tr[!class]') as $element) {
   $fila = str_get_dom($element->html());
      $input=$fila('input');
   $select=$fila('select')[0];
   $nselect=$select->name;
   $vselect=str_get_dom($select->html());
   $vselect=$vselect("option[selected]")[0]->getInnerText();
   
   switch ($vselect) {
      case "Sitio Web URL":
    $label="Sitio Web";
    $icon='<i class="fas fa-link  fa-2x"></i>';
          
         break;
      case "Facebook URL":
          $label=$vselect;
    $icon='<i class="fab fa-facebook  fa-2x"></i>';
         break;
      case "Instagram URL":
          $label=$vselect;
    $icon='<i class="fab fa-instagram  fa-2x"></i>';
         break;
      default:
          $label=$vselect;
    $icon='<i class="fas fa-link  fa-2x"></i>';
  }
   $data.='<div class="row clearfix">
                                        <div class="col-lg-2 col-md-2 col-sm-4 col-xs-5 form-control-label">
                                            <label for="url">'.$icon.' '.$label.':</label>
                                        </div>
                                        <div class="col-lg-10 col-md-10 col-sm-8 col-xs-7">
                                            <div class="form-group">
                                                <div class="form-line">
                                                <input type="text" class="form-control" id="facebook" name="'.$fila('input')[0]->name.'" value="'.$fila('input')[0]->value.'">
                                                    
                                                    <input type="hidden" name="'.$nselect.'" value="'.$vselect.'">
                                                </div>
                                            </div>
                                        </div>
                                    </div>';
        
        
        
    
   }
  
  
  return  $data;
  
 }

In your template tag can use

{exp:tcdcl_utilities:getGridValues}

 {field:redes_sociales_links}
 
{/exp:tcdcl_utilities:getGridValues}

tcdcl_utilities are the name of your custom plugin and getGridValues are the function

With this code(you can customize) the grid field type have a custom aparience

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.