Skip to content

Instantly share code, notes, and snippets.

View henrytran9x's full-sized avatar

Andy Tran henrytran9x

  • Mercury
  • Vietnam
View GitHub Profile
@henrytran9x
henrytran9x / template.php
Created October 2, 2015 01:17
This update template Hosting
<?php
function hosting_default_layouts() {
return 'W3sia2V5IjoiZGVmYXVsdCIsInRpdGxlIjoiRGVmYXVsdCIsInNlY3Rpb25zIjpbeyJrZXkiOiJoZWFkZXIiLCJ0aXRsZSI6IkhlYWRlciIsIndlaWdodCI6MCwiZnVsbHdpZHRoIjoibm8iLCJiYWNrZ3JvdW5kY29sb3IiOiIiLCJzdGlja3kiOmZhbHNlLCJ2cGhvbmUiOmZhbHNlLCJ2dGFibGV0IjpmYWxzZSwidmRlc2t0b3AiOmZhbHNlLCJocGhvbmUiOmZhbHNlLCJodGFibGV0IjpmYWxzZSwiaGRlc2t0b3AiOmZhbHNlLCJjb2xwYWRkaW5nIjoiIiwiY3VzdG9tX2NsYXNzIjoiaGVhZGVyX3dyYXBwZXIiLCJyZWdpb25zIjpbeyJrZXkiOiJsb2dvIiwidGl0bGUiOiJMb2dvIiwid2VpZ2h0IjowLCJjb2x4cyI6IjQiLCJjb2xzbSI6IjQiLCJjb2xtZCI6IjMiLCJjb2xsZyI6IjMifSx7ImtleSI6ImNhbGxfdXMiLCJ0aXRsZSI6IkNhbGwgVXMiLCJ3ZWlnaHQiOjEsImNvbHhzIjoiNiIsImNvbHNtIjoiNiIsImNvbG1kIjoiNiIsImNvbGxnIjoiNiJ9LHsia2V5Ijoic2VhcmNoIiwidGl0bGUiOiJTZWFyY2giLCJ3ZWlnaHQiOjIsImNvbHhzIjoiNCIsImNvbHNtIjoiNCIsImNvbG1kIjoiMSIsImNvbGxnIjoiMSJ9LHsia2V5IjoibG9naW4iLCJ0aXRsZSI6IkxvZ2luIiwid2VpZ2h0IjozLCJjb2x4cyI6IjQiLCJjb2xzbSI6IjQiLCJjb2xtZCI6IjIiLCJjb2xsZyI6IjIifV19LHsia2V5IjoibmF2aWdhdGlvbiIsInRpdGxlIjoiTmF2aWdhdGlvbiIsIndlaWdodCI6MSwiZnVsb
@henrytran9x
henrytran9x / style.less
Created October 7, 2015 04:02
Set Responsive Text Alignment in Bootstrap 3
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }
@henrytran9x
henrytran9x / cart.php
Last active October 10, 2015 13:26
You are here Home » Drupal code snippets Programmatically show number of items in Drupal Commerce shopping cart
<?php
// http://kahthong.com/2012/08/programmatically-show-number-items-drupal-commerce-shopping-cart
global $user;
$quantity = 0;
$order = commerce_cart_order_load($user->uid);
if ($order) {
$wrapper = entity_metadata_wrapper('commerce_order', $order);
$line_items = $wrapper->commerce_line_items;
$quantity = commerce_line_items_quantity($line_items, commerce_product_line_item_types());
$total = commerce_line_items_total($line_items);
@henrytran9x
henrytran9x / reset.less
Created October 27, 2015 10:08 — forked from joshuapowell/reset.less
LESS: Global LESS CSS reset that gives elements default formatting.
/**
* Global Reset of all HTML Elements
*
* Resetting all of our HTML Elements ensures a smoother
* visual transition between browsers. If you don't believe me,
* try temporarily commenting out this block of code, then go
* and look at Mozilla versus Safari, both good browsers with
* a good implementation of CSS. The thing is, all browser CSS
* defaults are different and at the end of the day if visual
* consistency is what we're shooting for, then we need to
@henrytran9x
henrytran9x / facebook_api.php
Last active May 3, 2016 08:09
This API facebook URL get comment count,share count , like count from Link ..this Render json string
<?php
public static function get_the_fb_like( $url = '' ){
$pageURL = 'http://nextopics.com';
$url = ($url == '' ) ? $pageURL : $url; // setting a value in $url variable
$params = 'SELECT comment_count, share_count, like_count FROM link_stat WHERE url = "'.$url.'"';
$component = urlencode($params);
$url = 'http://graph.facebook.com/fql?q='.$component;
$fbLIkeAndSahre = json_decode(file_get_contents($url));
$getFbStatus = $fbLIkeAndSahre->data['0'];
return $getFbStatus;
@henrytran9x
henrytran9x / page.tpl.php
Created December 1, 2015 02:11
Update page theme Planify
<?php
/**
* @file
* Default theme implementation to display a single Drupal page.
*
* Available variables:
*
* General utility variables:
* - $base_path: The base URL path of the Drupal installation. At the very
* least, this will always default to /.
@henrytran9x
henrytran9x / quicksetting.js
Created December 4, 2015 10:37
Code script change color,layourt sites !
(function($){
$(document).ready(function(){
var relativeDir = Drupal.settings.paththeme+'/css/';
/* ***************************************
* Reading Cookies for stored values
*******************************************/
(function(){
if(readCookie("ssTruckingStyle") !== null){
var styleVal = readCookie("ssTruckingStyle");
@henrytran9x
henrytran9x / main.js
Created December 9, 2015 04:46
Run a JavaScript only on the First Page Load / only on Succeeding Page loads
// Note: this example makes use of jquery.cookie Plugin by Klaus Hartl, so make sure you include it, too.
(function ($) {
$( document ).ready(function() {
var cookieName = 'firstPageLoad';
var cookieValue = 1;
// if the cookie doesn't exist we're on the first page load...
if (!$.cookie(cookieName)) {
// and set a cookie that is valid for the entire domain
$.cookie(cookieName, cookieValue, { path: '/'});
@henrytran9x
henrytran9x / gist:7321a78e6eeeea421f45
Created December 10, 2015 09:48
All file make build Drupal
The extensions that are specific for Drupal, or that have a specific meaning in Drupal, are the following ones:
The .api.php extension is used for the file describing the hooks used by a module, such as system.api.php.
The .install extension is used for the file that is used when a module is installed, such as system.install. It is also loaded when Drupal is verifying the requirements needed from a module.
The .inc extension is used for any secondary file that contains code that is loaded only when necessary. If the code is used in specific cases, such as when a specific menu callback is being invoked, then the code is moved in a separated .inc file. Often, you will find modules using a file with the .admin.inc extension (e.g. node.admin.inc) that includes all the code necessary to run the administrative interface, and a file with .pages.inc extension (e.g. node.pages.inc) that contains the code executed for other menu callbacks. If a module implements tokens, in Drupal 7 you will find files us
@henrytran9x
henrytran9x / mymodule.php
Created December 28, 2015 08:27
This module load field follow condition type field Drupal 7
<?php
public function load_fields($entity_type, $bundle_name) {
$instances = field_info_instances($entity_type, $bundle_name); // Load entity tye and bundle_name
$fields = array();
foreach($instances as $key => $instance) {
foreach($instance as $field_name => $instance_field)
{
$field_info = field_info_field($field_name);
if($field_info['type'] === 'text') { // Get Type Fields 'text' , You can conndition type other