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 / 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);
@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 / foo.module
Created February 14, 2014 18:23
Use of hook_cron_queue_info
<?php
/**
* Implements hook_Cron_queue_info().
*/
function foo_cron_queue_info() {
$queues['vehicle_new_queue'] = array(
'worker callback' => 'vehicle_new_queue_run',
'time' => 60,
);
@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 / drupal.foo.js
Last active November 13, 2024 15:44
Drupal - Execute custom code on ajax success call
(function ($) {
Drupal.fooModule = Drupal.fooModule || {};
Drupal.fooModule.success = function (response, status) {
// do some cusotm coding if needed.
// Call original method with main functionality.
Drupal.ajax.prototype.success.call(this, response, status);
};
Drupal.behaviors.fooModule = {