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 / custom.php
Created June 1, 2015 16:37
This code convert string Vietnam
<?php
function convert_string_vietnam($text)
{
$text = html_entity_decode ($text);
$text = preg_replace("/(ä|à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ)/", 'a', $text);
$text = str_replace("ç","c",$text);
$text = preg_replace("/(è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ)/", 'e', $text);
$text = preg_replace("/(ì|í|î|ị|ỉ|ĩ)/", 'i', $text);
$text = preg_replace("/(ö|ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ)/", 'o', $text);
<?php
/**
* Theme_menu_tree doesn't provide any context information
* THIS SUCKS
* But you can use hook_block_view_alter to change the theme wrapper
* OUF!
*/
function MYTHEME_menu_tree(&$variables) {
@henrytran9x
henrytran9x / template.tpl.php
Created July 14, 2015 09:30
Customizing the Drupal Search Form in Drupal 7
<?php
/*
Implementing hook_form_alter() to change classes and add a wrapper function
*/
/**
* Implements hook_form_alter().
*/
function MYTHEME_form_alter(array &$form, array &$form_state = array(), $form_id = NULL) {
@henrytran9x
henrytran9x / my_module.info
Last active September 5, 2015 18:49
This module example template render form
name = My Module
description = This module exmaple
core = 7.x
version = 1.0
@henrytran9x
henrytran9x / gist:294db70d67c394436ca7
Last active September 10, 2015 02:05
Problems with display update and cart pricing after Commerce 7.x-1.11 update
commerce_pricing_attributes.module | 46 +++++++++++++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/commerce_pricing_attributes.module b/commerce_pricing_attributes.module
index d7b979e..4a39c0e 100644
--- a/commerce_pricing_attributes.module
+++ b/commerce_pricing_attributes.module
@@ -929,6 +929,9 @@ function commerce_pricing_attributes_add_to_cart_submit($form, $form_state){
elseif (isset($form_state['products'])) {
@henrytran9x
henrytran9x / template.php
Last active September 11, 2015 07:24
Hosting template
<?php
/** template_preprocess_page();
* @param $vars
*/
function hosting_preprocess_page(&$vars) {
global $theme;
if (drupal_is_front_page()) {
@henrytran9x
henrytran9x / Data.sql
Created September 14, 2015 16:30
This View create Best Seller by Commerce Product
/**
* Get a list of the top selling products on a Drupal Commerce site
* If you have different product types - add them to the in list.
* Based on https://drupal.org/node/1292104#comment-6866420 by tmsimont https://drupal.org/user/566678
*/
SELECT node.title AS product_title, node.nid AS product_nid, COUNT(cp.title) AS order_count
FROM commerce_order
LEFT JOIN field_data_commerce_line_items as fdcli ON commerce_order.order_id = fdcli.entity_id AND (fdcli.entity_type = 'commerce_order' AND fdcli.deleted = '0')
INNER JOIN commerce_line_item as cli ON fdcli.commerce_line_items_line_item_id = cli.line_item_id
@henrytran9x
henrytran9x / style.css
Created September 17, 2015 09:42
Find all element style sheet
[class^="col-"] {
padding-left: 0;
padding-right: 0;
}
[class$="-12"]
{
padding-left: 0;
padding-right: 0;
}
@henrytran9x
henrytran9x / mod_panel_style_mod_panel_style.info
Created September 22, 2015 09:12
This module create style content , allow add class for region panel
name = Mod Panel Style
description = Module support Style for Panel region
dependencies[] = panels
core = 7.x
version = 1.0
@henrytran9x
henrytran9x / contact-site-form.tpl.php
Created September 25, 2015 10:22
Contact customize
<style>
.site-contact-wrapper{
background-color: #eff1f5;
}
</style>
<div class="contact-map">
<div id="map"></div>
</div>
<div id="content-wrapper" class="site-contact-wrapper">
<div class="container">