Skip to content

Instantly share code, notes, and snippets.

View miteshmap's full-sized avatar
👨‍💻
Working from home

Mitesh Patel miteshmap

👨‍💻
Working from home
View GitHub Profile
@miteshmap
miteshmap / Readme
Created February 2, 2014 14:44
Omega 4 Theme installation.
Omega 4 Subtheme creation with SAss compile. (Must have ruby / compass / sass installed already)
create sub theme using Drush
drush help —filter=omega
this will show you command owiz (Omega-wizard.)
execute: drush owiz
And follow the steps. this will create a sub theme.
Now, to make css ,
@miteshmap
miteshmap / update_path.module.php
Created April 15, 2014 17:19
Update path for multiligual node
<?php
function foo_update_path() {
$nid = 1;
$node = node_load($nid);
foo_custom_module($node);
exit;
}
function foo_custom_module($node) {
@miteshmap
miteshmap / query_alter.module
Created October 1, 2014 12:35
alter entity field query to print for debug
/**
* Implements hook_query_alter().
*/
function evosys_redirect_query_alter($query) {
if ($query->hasTag('debug')) {
$sql = (string)$query;
$connection = Database::getConnection();
foreach ((array) $query->arguments() as $key => $val) {
$quoted[$key] = $connection->quote($val);
}
@miteshmap
miteshmap / custom_users.module
Last active August 29, 2015 14:07
Implemented use of hook_user_operations with batch.
/**
* Implements hook_user_operations().
*/
function custom_users_user_operations() {
$operations['custom_users_salesforce'] = array(
'label' => t('Create Salesforce Account'),
'callback' => 'custom_users_operations_create_salesforce_callback',
);
return $operations;
}
@miteshmap
miteshmap / foo.js
Created December 19, 2014 20:50
Drupal - write value to textarea with editor with js
(function ($) {
Drupal.fooModule = Drupal.enrich || {};
Drupal.fooModule.copyToTextarea = function($field, $value, settings) {
for (var editor in settings.wysiwyg.configs) break;
$("textarea[name^='"+ $field +"']").val($.trim($value));
var editorid = $("textarea[name^='"+ $field +"'].text-full").attr('id');
if (typeof editorid != 'undefined' && editorid.length > 0) {
if (editor == 'tinymce') {
tinyMCE.execInstanceCommand(editorid, 'mceSetContent', false, $.trim(html));
@miteshmap
miteshmap / panels.module
Last active August 29, 2015 14:17
ltrim returns wrong block delta for "Edit block" link.
<?php
// Line - 1811 - under "panels_get_pane_links_alter"
// remove the prefix block- to get the name.
$name_of_block = ltrim( $prefixed_name, $subtype_prefix_hyphen);
// correct Method
if (substr($prefixed_name, 0, strlen($subtype_prefix_hyphen)) == $subtype_prefix_hyphen) {
$name_of_block = substr($prefixed_name, strlen($subtype_prefix_hyphen));
}
@miteshmap
miteshmap / foo.module
Last active December 29, 2015 02:09
Add custom View Mode for entity
<?php
/**
* Implements hook_entity_info_alter().
*/
function foo_entity_info_alter(&$entity_info) {
$entity_info['node']['view modes']['another_teaser'] = array(
'label' => t('Another teaser'),
'custom settings' => TRUE,
);
@miteshmap
miteshmap / foo.module
Last active December 29, 2015 12:49
Implements hook_rule_condition_info - add condition to rules.
<?php
/**
* Implements hook_rules_condition_info()
*/
function foo_rules_condition_info() {
return array(
'foo_check' => array(
'label' => t('Check foo condition'),
'parameter' => array(
@miteshmap
miteshmap / gist:7914634
Created December 11, 2013 17:21
FACEBOOK SHARE BUTTON
$fb_url = "https://www.facebook.com/sharer.php?
&p[url]=http://bit.ly/myelection
&p[images][0]=http://election.gv.my/assets/vote.png
&p[title]=My customized title
&p[summary]=My customized summary";
@miteshmap
miteshmap / foo.php
Created January 3, 2014 08:45
Get user city /state/ country information from IP Address.
<?php
function getInfo_of_ip($ip){
$url = "http://api.geoio.com/q.php?key=fC3tzSLwbhXWXnTS&qt=geoip&d=comma&q=".$ip;
$timeout = 5;
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$d = curl_exec($ch);