Breaking

Followers

Tuesday, 16 January 2018

1/16/2018 01:47:00 am

3 Character Country Codes Using Google Maps Api

Is there a way I can get the 3 char country code in Google maps’s Reverse Geocoding?
The below query returns the 2 char country code (ISO 3166-1 encoding). But I need to have the 3 char country code.

HTML:


<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<script src="https://maps.googleapis.com/maps/api/js?libraries=places"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<link type="text/css" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500">
</head>

<body>

<div id="locationField">
  <input id="autocomplete" placeholder="Enter your address" type="text" />
</div>
<table id="address">
  <tr>
    <td class="label">City</td>
    <td class="wideField" colspan="3">
      <input class="field" id="locality" disabled="true" />
    </td>
  </tr>
  <tr>
    <td class="label">State</td>
    <td class="slimField">
      <input class="field" id="administrative_area_level_1" disabled="true" />
    </td>
  </tr>
  <tr>
    <td class="label">Country</td>
    <td class="wideField" colspan="2">
      <input class="field" id="country" disabled="true" />
    </td>
    <td class="label">Country Code</td>
    <td class="shortField">
      <input class="field" id="country_code" disabled="true" />
    </td>
  </tr>
  <tr>
    <td class="label">latitude</td>
    <td class="wideField" colspan="3">
      <input class="field" id="lat" disabled="true" />
    </td>
  </tr>
  <tr>
    <td class="label">longitude</td>
    <td class="wideField" colspan="3">
      <input class="field" id="lng" disabled="true" />
    </td>
  </tr>
</table>


</body>
</html>


Javascript:

  // This example displays an address form, using the autocomplete feature
// of the Google Places API to help users fill in the information.

function fillInAddress() {
  // country code array with two letter and thre letter.
  var countries = [
    {"two" :"AF","three" : "AFG" },
    {"two" :"AL","three" : "ALB" },
    {"two" :"DZ","three" : "DZA" },
    {"two" :"AS","three" : "ASM" },
    {"two" :"AD","three" : "AND" },
    {"two" :"AO","three" : "AGO" },
    {"two" :"AI","three" : "AIA" },
    {"two" :"AQ","three" : "ATA" },
    {"two" :"AG","three" : "ATG" },
    {"two" :"AR","three" : "ARG" },
    {"two" :"AM","three" : "ARM" },
    {"two" :"AW","three" : "ABW" },
    {"two" :"AU","three" : "AUS" },
    {"two" :"AT","three" : "AUT" },
    {"two" :"AZ","three" : "AZE" },
    {"two" :"BS","three" : "BHS" },
    {"two" :"BH","three" : "BHR" },
    {"two" :"BD","three" : "BGD" },
    {"two" :"BB","three" : "BRB" },
    {"two" :"BY","three" : "BLR" },
    {"two" :"BE","three" : "BEL" },
    {"two" :"BZ","three" : "BLZ" },
    {"two" :"BJ","three" : "BEN" },
    {"two" :"BM","three" : "BMU" },
    {"two" :"BT","three" : "BTN" },
    {"two" :"BO","three" : "BOL" },
    {"two" :"BO","three" : "BOL" },
    {"two" :"BA","three" : "BIH" },
    {"two" :"BW","three" : "BWA" },
    {"two" :"BV","three" : "BVT" },
    {"two" :"BR","three" : "BRA" },
    {"two" :"IO","three" : "IOT" },
    {"two" :"BN","three" : "BRN" },
    {"two" :"BN","three" : "BRN" },
    {"two" :"BG","three" : "BGR" },
    {"two" :"BF","three" : "BFA" },
    {"two" :"BI","three" : "BDI" },
    {"two" :"KH","three" : "KHM" },
    {"two" :"CM","three" : "CMR" },
    {"two" :"CA","three" : "CAN" },
    {"two" :"CV","three" : "CPV" },
    {"two" :"KY","three" : "CYM" },
    {"two" :"CF","three" : "CAF" },
    {"two" :"TD","three" : "TCD" },
    {"two" :"CL","three" : "CHL" },
    {"two" :"CN","three" : "CHN" },
    {"two" :"CX","three" : "CXR" },
    {"two" :"CC","three" : "CCK" },
    {"two" :"CO","three" : "COL" },
    {"two" :"KM","three" : "COM" },
    {"two" :"CG","three" : "COG" },
    {"two" :"CD","three" : "COD" },
    {"two" :"CK","three" : "COK" },
    {"two" :"CR","three" : "CRI" },
    {"two" :"CI","three" : "CIV" },
    {"two" :"CI","three" : "CIV" },
    {"two" :"HR","three" : "HRV" },
    {"two" :"CU","three" : "CUB" },
    {"two" :"CY","three" : "CYP" },
    {"two" :"CZ","three" : "CZE" },
    {"two" :"DK","three" : "DNK" },
    {"two" :"DJ","three" : "DJI" },
    {"two" :"DM","three" : "DMA" },
    {"two" :"DO","three" : "DOM" },
    {"two" :"EC","three" : "ECU" },
    {"two" :"EG","three" : "EGY" },
    {"two" :"SV","three" : "SLV" },
    {"two" :"GQ","three" : "GNQ" },
    {"two" :"ER","three" : "ERI" },
    {"two" :"EE","three" : "EST" },
    {"two" :"ET","three" : "ETH" },
    {"two" :"FK","three" : "FLK" },
    {"two" :"FO","three" : "FRO" },
    {"two" :"FJ","three" : "FJI" },
    {"two" :"FI","three" : "FIN" },
    {"two" :"FR","three" : "FRA" },
    {"two" :"GF","three" : "GUF" },
    {"two" :"PF","three" : "PYF" },
    {"two" :"TF","three" : "ATF" },
    {"two" :"GA","three" : "GAB" },
    {"two" :"GM","three" : "GMB" },
    {"two" :"GE","three" : "GEO" },
    {"two" :"DE","three" : "DEU" },
    {"two" :"GH","three" : "GHA" },
    {"two" :"GI","three" : "GIB" },
    {"two" :"GR","three" : "GRC" },
    {"two" :"GL","three" : "GRL" },
    {"two" :"GD","three" : "GRD" },
    {"two" :"GP","three" : "GLP" },
    {"two" :"GU","three" : "GUM" },
    {"two" :"GT","three" : "GTM" },
    {"two" :"GG","three" : "GGY" },
    {"two" :"GN","three" : "GIN" },
    {"two" :"GW","three" : "GNB" },
    {"two" :"GY","three" : "GUY" },
    {"two" :"HT","three" : "HTI" },
    {"two" :"HM","three" : "HMD" },
    {"two" :"VA","three" : "VAT" },
    {"two" :"HN","three" : "HND" },
    {"two" :"HK","three" : "HKG" },
    {"two" :"HU","three" : "HUN" },
    {"two" :"IS","three" : "ISL" },
    {"two" :"IN","three" : "IND" },
    {"two" :"ID","three" : "IDN" },
    {"two" :"IR","three" : "IRN" },
    {"two" :"IQ","three" : "IRQ" },
    {"two" :"IE","three" : "IRL" },
    {"two" :"IM","three" : "IMN" },
    {"two" :"IL","three" : "ISR" },
    {"two" :"IT","three" : "ITA" },
    {"two" :"JM","three" : "JAM" },
    {"two" :"JP","three" : "JPN" },
    {"two" :"JE","three" : "JEY" },
    {"two" :"JO","three" : "JOR" },
    {"two" :"KZ","three" : "KAZ" },
    {"two" :"KE","three" : "KEN" },
    {"two" :"KI","three" : "KIR" },
    {"two" :"KP","three" : "PRK" },
    {"two" :"KR","three" : "KOR" },
    {"two" :"KR","three" : "KOR" },
    {"two" :"KW","three" : "KWT" },
    {"two" :"KG","three" : "KGZ" },
    {"two" :"LA","three" : "LAO" },
    {"two" :"LV","three" : "LVA" },
    {"two" :"LB","three" : "LBN" },
    {"two" :"LS","three" : "LSO" },
    {"two" :"LR","three" : "LBR" },
    {"two" :"LY","three" : "LBY" },
    {"two" :"LY","three" : "LBY" },
    {"two" :"LI","three" : "LIE" },
    {"two" :"LT","three" : "LTU" },
    {"two" :"LU","three" : "LUX" },
    {"two" :"MO","three" : "MAC" },
    {"two" :"MK","three" : "MKD" },
    {"two" :"MG","three" : "MDG" },
    {"two" :"MW","three" : "MWI" },
    {"two" :"MY","three" : "MYS" },
    {"two" :"MV","three" : "MDV" },
    {"two" :"ML","three" : "MLI" },
    {"two" :"MT","three" : "MLT" },
    {"two" :"MH","three" : "MHL" },
    {"two" :"MQ","three" : "MTQ" },
    {"two" :"MR","three" : "MRT" },
    {"two" :"MU","three" : "MUS" },
    {"two" :"YT","three" : "MYT" },
    {"two" :"MX","three" : "MEX" },
    {"two" :"FM","three" : "FSM" },
    {"two" :"MD","three" : "MDA" },
    {"two" :"MC","three" : "MCO" },
    {"two" :"MN","three" : "MNG" },
    {"two" :"ME","three" : "MNE" },
    {"two" :"MS","three" : "MSR" },
    {"two" :"MA","three" : "MAR" },
    {"two" :"MZ","three" : "MOZ" },
    {"two" :"MM","three" : "MMR" },
    {"two" :"MM","three" : "MMR" },
    {"two" :"NA","three" : "NAM" },
    {"two" :"NR","three" : "NRU" },
    {"two" :"NP","three" : "NPL" },
    {"two" :"NL","three" : "NLD" },
    {"two" :"AN","three" : "ANT" },
    {"two" :"NC","three" : "NCL" },
    {"two" :"NZ","three" : "NZL" },
    {"two" :"NI","three" : "NIC" },
    {"two" :"NE","three" : "NER" },
    {"two" :"NG","three" : "NGA" },
    {"two" :"NU","three" : "NIU" },
    {"two" :"NF","three" : "NFK" },
    {"two" :"MP","three" : "MNP" },
    {"two" :"NO","three" : "NOR" },
    {"two" :"OM","three" : "OMN" },
    {"two" :"PK","three" : "PAK" },
    {"two" :"PW","three" : "PLW" },
    {"two" :"PS","three" : "PSE" },
    {"two" :"PA","three" : "PAN" },
    {"two" :"PG","three" : "PNG" },
    {"two" :"PY","three" : "PRY" },
    {"two" :"PE","three" : "PER" },
    {"two" :"PH","three" : "PHL" },
    {"two" :"PN","three" : "PCN" },
    {"two" :"PL","three" : "POL" },
    {"two" :"PT","three" : "PRT" },
    {"two" :"PR","three" : "PRI" },
    {"two" :"QA","three" : "QAT" },
    {"two" :"RE","three" : "REU" },
    {"two" :"RO","three" : "ROU" },
    {"two" :"RU","three" : "RUS" },
    {"two" :"RU","three" : "RUS" },
    {"two" :"RW","three" : "RWA" },
    {"two" :"SH","three" : "SHN" },
    {"two" :"KN","three" : "KNA" },
    {"two" :"LC","three" : "LCA" },
    {"two" :"PM","three" : "SPM" },
    {"two" :"VC","three" : "VCT" },
    {"two" :"VC","three" : "VCT" },
    {"two" :"VC","three" : "VCT" },
    {"two" :"WS","three" : "WSM" },
    {"two" :"SM","three" : "SMR" },
    {"two" :"ST","three" : "STP" },
    {"two" :"SA","three" : "SAU" },
    {"two" :"SN","three" : "SEN" },
    {"two" :"RS","three" : "SRB" },
    {"two" :"SC","three" : "SYC" },
    {"two" :"SL","three" : "SLE" },
    {"two" :"SG","three" : "SGP" },
    {"two" :"SK","three" : "SVK" },
    {"two" :"SI","three" : "SVN" },
    {"two" :"SB","three" : "SLB" },
    {"two" :"SO","three" : "SOM" },
    {"two" :"ZA","three" : "ZAF" },
    {"two" :"GS","three" : "SGS" },
    {"two" :"ES","three" : "ESP" },
    {"two" :"LK","three" : "LKA" },
    {"two" :"SD","three" : "SDN" },
    {"two" :"SR","three" : "SUR" },
    {"two" :"SJ","three" : "SJM" },
    {"two" :"SZ","three" : "SWZ" },
    {"two" :"SE","three" : "SWE" },
    {"two" :"CH","three" : "CHE" },
    {"two" :"SY","three" : "SYR" },
    {"two" :"TW","three" : "TWN" },
    {"two" :"TW","three" : "TWN" },
    {"two" :"TJ","three" : "TJK" },
    {"two" :"TZ","three" : "TZA" },
    {"two" :"TH","three" : "THA" },
    {"two" :"TL","three" : "TLS" },
    {"two" :"TG","three" : "TGO" },
    {"two" :"TK","three" : "TKL" },
    {"two" :"TO","three" : "TON" },
    {"two" :"TT","three" : "TTO" },
    {"two" :"TT","three" : "TTO" },
    {"two" :"TN","three" : "TUN" },
    {"two" :"TR","three" : "TUR" },
    {"two" :"TM","three" : "TKM" },
    {"two" :"TC","three" : "TCA" },
    {"two" :"TV","three" : "TUV" },
    {"two" :"UG","three" : "UGA" },
    {"two" :"UA","three" : "UKR" },
    {"two" :"AE","three" : "ARE" },
    {"two" :"GB","three" : "GBR" },
    {"two" :"US","three" : "USA" },
    {"two" :"UM","three" : "UMI" },
    {"two" :"UY","three" : "URY" },
    {"two" :"UZ","three" : "UZB" },
    {"two" :"VU","three" : "VUT" },
    {"two" :"VE","three" : "VEN" },
    {"two" :"VE","three" : "VEN" },
    {"two" :"VN","three" : "VNM" },
    {"two" :"VN","three" : "VNM" },
    {"two" :"VG","three" : "VGB" },
    {"two" :"VI","three" : "VIR" },
    {"two" :"WF","three" : "WLF" },
    {"two" :"EH","three" : "ESH" },
    {"two" :"YE","three" : "YEM" },
    {"two" :"ZM","three" : "ZMB" },
    {"two" :"ZW","three" : "ZWE" }
    ];//etc
  
  // Get the place details from the autocomplete object.
  var place = autocomplete.getPlace();

  for (var component in componentForm) {
    document.getElementById(component).value = '';
  }

  // Get each component of the address from the place details
  // and fill the corresponding field on the form.
  for (var i = 0; i < place.address_components.length; i++) {
    var addressType = place.address_components[i].types[0];
    if (componentForm[addressType]) {
      var val = place.address_components[i][componentForm[addressType]];
      document.getElementById(addressType).value = val;
    }
    // for the country, get the country code (the "short name") also
    if (addressType == "country") {
      console.log(getKeyByParameter(countries, place.address_components[i].short_name));
      document.getElementById("country_code").value = getKeyByParameter(countries, place.address_components[i].short_name);
    }
  }
}

var placeSearch, autocomplete;
var componentForm = {
  locality: 'long_name',
  administrative_area_level_1: 'short_name',
  country: 'long_name',
};

function initAutocomplete() {
  // Create the autocomplete object, restricting the search to geographical
  // location types.
  autocomplete = new google.maps.places.Autocomplete(
    /** @type {!HTMLInputElement}     */
    (document.getElementById('autocomplete')), {
      types: ['(cities)']
    });

  // When the user selects an address from the dropdown, populate the address
  // fields in the form.
  // Get Latitude and longitude
  google.maps.event.addListener(autocomplete, 'place_changed', function() {
    var place = autocomplete.getPlace();
    console.log(place);
    document.getElementById('lat').value = place.geometry.location.lat();
    document.getElementById('lng').value = place.geometry.location.lng();
    fillInAddress();
  });
}
google.maps.event.addDomListener(window, 'load', initAutocomplete);



// function for revers coding 
var getKeyByParameter = function(obj, parameter) {
var returnVal = "";

jQuery.each(obj, function(key, info) {
    if (info.two == parameter) {
       returnVal = info.three;
        return false; 
    };   
});

return returnVal;       

}



1/16/2018 01:43:00 am

How to create Batch in Drupal 6, 7 with Example


URL = http://tylerfrankenstein.com/code/drupal-batch-example

/**
* The batch processor.
*/
function my_module_batch_fix_process($word, &$context) {
// Do heavy lifting here…
// Display a progress message…
$context[‘message’] = “Now processing $word…”;
}

/**
* The batch finish handler.
*/
function my_module_batch_fix_finished($success, $results, $operations) {
if ($success) {
drupal_set_message(‘Fix is complete!’);
}
else {
$error_operation = reset($operations);
$message = t(‘An error occurred while processing %error_operation with arguments: @arguments’, array(
‘%error_operation’ => $error_operation[0],
‘@arguments’ => print_r($error_operation[1], TRUE)
));
drupal_set_message($message, ‘error’);
}
drupal_set_message(l(‘Run again’, ‘my_module/batch_fix’));
}
1/16/2018 01:38:00 am

We can use third level category in menubar in wordpress.




$thiscat =  get_query_var('cat'); // The id of the current category
  $catobject = get_category($thiscat,false); // Get the Category object by the id of current category
  if($thiscat)
   $topcat = get_top_parent_cat($thiscat);
  
  $parentcat = $catobject->category_parent;
  global $wp_query;
  $page_title = $wp_query->post->post_title;
  $current_dest_menu = 'level-3';
  if($page_title=='Destinations' || $topcat==158)   
   $current_dest_menu = 'level-3 current-menu-item';
  
  $custom_menu = '<li class="'.$current_dest_menu.'"><a href="'.get_bloginfo("url").'/destinations/">Destinations</a>
            <ul class="sub-menu">';
   
   $categories = get_categories('&orderby=name&order=ASC&child_of=158&hide_empty');
   $count =1;
   $x = 0;
   foreach($categories as $category) { 
   
   if ($category->category_parent ==158){
    $countchildren = count (get_term_children( $category->cat_ID, 'category' ));
    
    if($parentcat==$category->cat_ID){
     if($countchildren>1)
      $menu_class_name= "col-3-level current-menu-ancestor";
     else
      $menu_class_name= "col-2-level current-menu-ancestor"; 
    } else{
     if($countchildren>1)
      $menu_class_name= "col-3-level";
     else
      $menu_class_name= "col-2-level";
    }
    
     $custom_menu .=' <li class="'.$menu_class_name.'"><a href="'.get_category_link($category->cat_ID).'">'.$category->name.'</a><ul>';
     
     
       $args = array(                                                  
           'orderby' => 'name',     
           'hide_empty' => true,
           'child_of' =>$category->cat_ID
           );

         $child_categories = get_categories($args); 
        foreach($child_categories as $category) { 
         if($thiscat==$category->cat_ID) 
          $custom_menu .='<li class="current-menu-item"><a href="'.get_category_link($category->cat_ID).'">'.$category->cat_name.'</a></li>';
         else
          $custom_menu .='<li><a href="'.get_category_link($category->cat_ID).'">'.$category->cat_name.'</a></li>'; 

        }
    $custom_menu .='</ul></li>' ;       
            }} 
           $custom_menu .='</ul></li>';
          
    wp_nav_menu( array(
     'menu'=>'Main Navigation',
     'container_class'   => 'mainMenu align-right',     
     'items_wrap'     => '<ul id="menu-main-navigation" class="menu">'.$custom_menu.'%3$s</ul>'
    ) );
    
1/16/2018 01:33:00 am

How To Prevent To Customer To Add Same Credit Card On Stripe In Php

I’ve written the following php code in my web app to check for this.
# Retrieve the customer we’re adding this token to
$customer = \Stripe\Customer::retrieve($customer_id)
            ->sources->all(array('limit'=>15, 'object' => 'card'));

# Retrieve the submitted token

$stripe_token =\Stripe\Token::retrieve($_POST['stripeToken']);

# The fingerprint of the card is stored in ['card']['fingerprint']

$key = searcharray($fingerprint, 'fingerprint',$customer);

# Check if the card fingerprint submitted matches one of the customer’s current sources

if($fingerprint==$key){
   echo 'That card already exists on your account.';
}

# add the search array function given below

function searcharray($value, $key, $array) {


   foreach ($array->data as $k => $val) {

       if ($val[$key] == $value) {
           return $val[$key];
       }
   }
   return null;
}

Tuesday, 14 November 2017

11/14/2017 01:51:00 am

Diffrence between ajax and jquery




Diffrence between ajax and jquery
AJAX JQUERY
AJAX is a powerful tool which cannot use HTML since it is a simple tool and it can not reload the page after it is once loaded. JQuery is a light weight language that focuses the interaction in the HTML elements.
AJAX is a combination of several technologies such as CSS HTML DOM and many more. In combination with these technologies AJAX provides new functionalities. JQuery cannot provide a new functionality by combining with other technologies.
AJAX should be accessed in a proper procedure to retrieve data from the server. JQuery can be accessed through front-end therefore JQuery does not require understanding of the complete procedure to setup a page.
Heavy usage of AJAX often leads to the server overload due to more number of connections created. There is no chance for overload of server while using JQuery since there is no such heavy usage in JQuery.
11/14/2017 01:46:00 am

Difference Between Mysql_fetch_array And Mysql_fetch_assoc And Mysql_fetch_row

Difference Between Mysql_fetch_array And Mysql_fetch_assoc And Mysql_fetch_row


Mysql_fetch_row()

Mysql_fetch_row fetch result row an numeric way. This function return a row where the valuew will come in the order as they are defined in the query, and the keys will span from 0 to one less than the number of columns selected.


$result = mysql_query("select * from user");
while ($rows = mysql_fetch_row($result))
{
    echo $rows[0];
    echo "<br>";
    echo $rows[1];
}

Mysql_fetch_assoc()

Fetch a result row as an associative array.This function will return a
row as an associative array where the column names will be the keys storing
corresponding value

$result = mysql_query("select  * from user");
while ($rows = mysql_fetch_assoc($result))
{
    echo $rows['id'];
    echo "<br>";
    echo $rows['name'];
}

Mysql_fetch_array()

Fetch a result row as an associative array, a numeric array and also it fetches by both associative & numeric array.This function will actually return an array with both the contents of mysql_fetch_row and mysql_fetch_assoc merged into one. It will both have numeric and string keys.



$result = mysql_query("select  * from user");
while ($rows = mysql_fetch_arrayc($result))
{
    echo $rows['id'];
    echo "<br>";
    echo $rows['name'];
}


Mysql_fetch_object()

Fetch a result row as an object.

$result = mysql_query("select  * from user");
while ($rows = mysql_fetch_assoc($result))
{
    echo $rows->id;
    echo "<br>";
    echo $rows->name;
}

Friday, 29 September 2017

9/29/2017 04:13:00 am

What are Drupal Behaviors?

Drupal has a ‘behaviors’ system to provide a modular and better way for attaching JavaScript functionality to place elements on a page.  Drupal Behaviors allows you to override or extend the existing behavior. Find out how this Drupal core functionality helps.


Drupal is a versatile content management system that interlocks both the database and the server, which offers a revolutionary programming edge where there are options to insert the behavior to override JavaScript for an appealing interface. These Drupal behaviors are event triggered programs that get attached to the page elements to be changed. While behaviours can be attached to specific contents, multiple behaviours are also attached and can be ablazed multiple times for a quick remake.
Drupal behaviors handles infinite scroll’s AJAX call, since it has the ability to override or extend an existing behavior by a bouncing effect where it is an alternate for jQuery.ready.
It can be reattached and you can attach behaviors to a specific context. Drupal has a “behaviors” system to provide a modular and better way for attaching JavaScript functionality to place elements on a page. In short, the advantage of Behaviors over the document.ready() is that they are automatically re-applied to any content that is loaded through AJAX. 

Drupal 7 has two handles:
• To add an element to a page, you use ‘attach’
• To remove an element, you use ‘detach’
drupal.js has a $(document).ready() function that calls the Drupal.attachBehaviors() function, which, in turn, cycles through the Drupal.behaviors object, calling every one of its properties Drupal.behaviors runs when the document is ready and when Ajax calls are made. If you want to apply Java scripts to the elements during the page loads and all the elements are created using AJAX, Drupal.behaviors is the ideal solution.
With jQuery, you learn to put all your code inside the $(document).ready() function. When this is done, your code will run, manipulating elements and binding behaviors to events as per the instructions as soon as the DOM has  loaded. 




http://www.faichi.com/blog/what-are-drupal-behaviors






Friday, 15 September 2017

9/15/2017 02:45:00 am

How to Create Responsive Tables using CSS

This is the exact same table, only has @media queries applied to is so that when the screen is too narrow, it reformats (via only CSS) to make each row a bit like it’s own table. This makes for much more repetition and vertical space needed, but it fits within the horizontal space, so only natural vertical scrolling is needed to explore the data.

Attach to Your Markup

Transaction id Task/Service Name Tasker Name Currency Amount Date
tr_1AvAiOHqtdB22t0rH7XY6uJy Ahaahahaha Jason  CAD $500041.00 Aug-26-2017
tr_1AvAiOHqtdB22t0rH7XY6uJy Ahaahahaha Jason  CAD $500041.00 Aug-26-2017
tr_1AvAiOHqtdB22t0rH7XY6uJy Ahaahahaha Jason  CAD $500041.00 Aug-26-2017
tr_1AvAiOHqtdB22t0rH7XY6uJy Ahaahahaha Jason  CAD $500041.00 Aug-26-2017



Add to Your CSS


.table-payment table{border:0!important;border-collapse:collapse;margin:0;padding:0;width:100%;table-layout:fixed;}
.table-payment table caption{font-size:1.5em;margin:.5em 0 .75em;}
.table-payment table tr{background:#f8f8f8;border:1px solid #ddd;padding:.35em;}
.table-payment table th,
.table-payment table td{padding:.625em;text-align:center;color:#5f5b5b;font-size:14px;line-height:18px;word-wrap: break-word;}
.table-payment table th{font-weight:700;color:#000;background-color:#ededed}
.table-payment table tr:nth-child(even) td{background-color:#f8f8f8}
.table-payment table tr:nth-child(odd) td{background-color:#fff}

@media screen and (max-width:600px){.table-payment table{border:0;}
.table-payment table caption{font-size:1.3em;}
.table-payment table thead{border:none;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px;}
.table-payment table tr{display:block; padding:0; border:0;border-top:1px solid #ddd}
.table-payment table td{border-bottom:1px solid #ddd;display:block;font-size:.8em;text-align:right;min-height:35px }
.table-payment table td:before{/*
    * aria-label has no advantage, it won't be read inside a table
    content:attr(aria-label);*/
content:attr(data-label);float:left;font-weight:bold;text-transform:uppercase;}
.table-payment table td:last-child{border-bottom:0;}
.DashboardRightContent .paymentBox{padding-bottom:0;}

.table-payment table tr:nth-child(even),
.table-payment table tr:nth-child(even) td{background-color:#f8f8f8}
.table-payment table tr:nth-child(odd),
.table-payment table tr:nth-child(odd) td{background-color:#fff}
.table-payment table tr + tr{border-top:1px solid #0085e9}

/*.table-payment table tr td:nth-child(even){background-color:#fff}
.table-payment table tr td:nth-child(odd){background-color:#f8f8f8}*/
}
@media screen and (max-width:350px){.table-payment table td{font-size:.7em;}

}

Saturday, 15 July 2017

7/15/2017 12:15:00 am

Create custom rule in Drupal 7


Let’s start with the announcement hook_rules_event_info (), which also should be placed in the file module.rules.inc
/**
* Implementation of hook_rules_event_info().
* @ingroup rules
*/

function nirvana_like_rules_event_info() {
  return array(
    'nirvana_like_skill_endorsed_plus' => array(
      'label' => t('After adding skill endorsed'),
      'module' => 'nirvana_like',
      'group' => 'Skill endorsed',
      'variables' => array(
        'skill_userid' => array('type' => 'user', 'label' => t('This id of accept a bid.')),
        'skill_tid' => array('type' => 'taxonomy_term', 'label' => t('The user who is post node.')),
        'endorsed_user_id' => array('type' => 'user', 'label' => t('The posted node services or task.')),     
      ),
    ),
   
  );
}
Now, invoke this event in your custom function.

Ex.
function hook(){
  rules_invoke_event('nirvana_like_skill_endorsed_minus',user_load($_POST['skill_user']),taxonomy_term_load($_POST['tid']),user_load($_POST['endorsed_userid']));
}


Hope it will work what you are looking for!

Friday, 16 June 2017

6/16/2017 11:49:00 pm

Create custom node view modes


In Drupal 7 we can create additional view modes by simply implementing hook_entity_info_alter() in our custom module.

/**
* Implements hook_entity_info_alter().
*/
function MYMODULE_entity_info_alter(&$entity_info) {
  $entity_info['node']['view modes']['another_teaser'] = array(
    'label' => t('Another teaser'),
    'custom settings' => TRUE,
  );
}


To get the most out of this we’ll propably want to add a custom node.tpl.php template for this view mode. Custom node template enables easy and flexible theming and we can use standard hook_preprocess_node() function for example to control the variables we have available in the template. To make Drupal use a different .tpl.php file for view mode we need to add a new template suggestion in hook_preprocess_node().

/**
* Implements hook_preprocess_node().
*/
function MYMODULE_preprocess_node(&$vars) {
  if($vars['view_mode'] == 'another_teaser') {
    $vars['theme_hook_suggestions'][] = 'node__' . $vars['type'] . '__another_teaser';
  }
} 

6/16/2017 11:41:00 pm

Programmatically create and update field collection item for the node with entity API

To attach or create field-collection item for node having node id say 16.

$node= node_load(16);
$field_collection_val= entity_create('field_collection_item', array('field_name'=> 'field_collection1'));
// Attach to the node
$field_collection_value->setHostEntity('node', $node); .
$field_collection_value->field_collection1[LANGUAGE_NONE][0]['value'] = 'your fetch data here/some data here';
// Save field-collection item.
$field_collection_value->save();


To modify/update (load/edit/save) values from existing field collection item of node having node id 16

$nid = 16;
$node = node_load($nid);
// Get field collection item value.
$field_collection_item_value = $node->field_collection1[LANGUAGE_NONE][0]['value'];
 // Delete field collection item.
entity_delete_multiple('field_collection_item', array($field_collection_item_value));