140 |
|
|
Macintosh |
|
|
EDIT
|
139 |
lsof | grep /Volumes/IMAJIN
diskutil unmountDisk force /Volumes/IMAJIN
|
|
see what is accessing disk / force unmount disk |
|
|
EDIT
|
138 |
|
|
Hosting |
|
|
EDIT
|
135 |
<?php
$reflFunc=new ReflectionFunction('name_of_function');
echo($reflFunc->getFileName().':'.$reflFunc->getStartLine());
?>
|
|
Find which file a function is defined in |
|
|
EDIT
|
134 |
Adds custom post type called "Reviews"
<?php
function create_post_type(){
register_post_type('review',
array(
'labels'=>array(
'name'=>__('Reviews'),
'singular_name'=>__('Review')
),
'public'=>true,
'has_archive'=>true,
'capabilities'=>array(
'edit_post'=>'edit_review',
'edit_posts'=>'edit_reviews',
'publish_posts'=>'publish_review',
'read_post'=>'read_review',
),
)
);
}
add_action('init','creat
|
|
Custom Post Types |
|
|
EDIT
|
71 |
|
|
In the Weeds |
|
|
EDIT
|
132 |
<?php
// Adds custom post type for Projects and Services
function create_post_type(){
register_post_type('project',
array(
'labels' => array(
'name' => __('Projects'),
'singular_name' => __('Project')
),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => true,
'capabilities' => array(
'edit_post' => 'edit_project',
'edit_posts' => 'edit_projects',
'publish_posts' => 'publish_project',
|
|
Post referencing setup |
|
|
EDIT
|
36 |
|
|
Covidien Portal |
|
|
EDIT
|
131 |
|
|
Foster Care Training |
|
|
EDIT
|
130 |
|
|
AG & Associates |
|
|
EDIT
|
129 |
|
|
Calvin Associates |
|
|
EDIT
|
128 |
|
|
Ferber Law |
|
|
EDIT
|
127 |
|
|
Oakland Police |
|
|
EDIT
|
78 |
|
|
Orgnsm (ROOT) |
|
|
EDIT
|
137 |
|
|
Tru frame |
|
|
EDIT
|
136 |
|
|
Lotto-rithm |
|
|
EDIT
|
133 |
|
|
Rate Your Customer / Rate My Contractor |
|
|
EDIT
|
125 |
|
|
IXIAS |
|
|
EDIT
|
19 |
|
|
NeuroGenesix |
|
|
EDIT
|
126 |
TTF - Works in most browsers except IE and iPhone
EOT - IE only
WOFF - Compressed, emerging standard
SVG - iPhone/iPad
|
|
Font-embed Rundown |
|
|
EDIT
|
124 |
jQuery(window).load(function(){
jQuery('.flexslider').flexslider( {
pauseOnHover: true,
controlsContainer: ".flex-container",
slideshowSpeed: 8000,
before: function(slider){
var currentSlide = slider.slides.eq(slider.currentSlide);
jQuery(currentSlide).find('.flex-caption').animate({'opacity':'0','right':'30px'},700);
},
after: function(slider){
var currentSlide = slider.slides.eq(slider.currentSlide);
jQuery(currentSlide).find('.fle
|
|
Using jQuery flexslider with animated captions callback |
|
|
EDIT
|
1 |
|
|
Topics |
|
|
EDIT
|
122 |
|
|
MySQL |
|
|
EDIT
|
121 |
DELETE FROM `field_config` WHERE `field_config`.`deleted` = 1;
|
|
Removes fields pending for deletion to uninstall a stuck module |
|
|
EDIT
|
120 |
<?php
function organic_context_config_page(){
$form = array();
$form['onthisdate_maxdisp'] = array(
'#type' => 'textfield',
'#title' => t('Maximum number of links'),
'#default_value' => variable_get('onthisdate_maxdisp', 3),
'#size' => 2,
'#maxlength' => 2,
'#description' => t("The maximum number of links to display in the block."),
'#required' => TRUE,
);
return system_settings_form($form);
}
?>
|
|
Reading/setting Drupal config variables |
|
|
EDIT
|
119 |
<?php
/////////////////// PAGE DEFINITIONS ///////////////////
function migrate_groups_menu(){
$menu["migrate_groups"] = array(
"title" => "Migrate grps",
"description" => "....",
"page callback" => "migrate_multigroup_to_collections",
"access callback" => TRUE,
);
return $menu;
}
/*function migrate_multigroup_to_collections() {
$content_type = 'thing';
$collection_field = 'field_context';
$multigroup_fields = array(
'field_connection',
'field_title_
|
|
Migrates multigroups in D6 to field collections in D7 |
|
|
EDIT
|
116 |
|
|
Google |
|
|
EDIT
|
115 |
|
|
Organic Connectivity Module |
|
|
EDIT
|
114 |
<?php
function loadchildrens($context){
$sql_children = "SELECT node.nid AS nid,
node.vid AS node_vid,
node.title AS node_title
FROM node node
LEFT JOIN content_field_connection node_data_field_connection ON node.vid = node_data_field_connection.vid
WHERE (node.type in ('category')) AND (node_data_field_connection.field_connection_nid = ".$context.")
ORDER BY node_title ASC";
$db_query_children = db_query( $sql_children );
while( $row = db_fetch_array($db_query_children) ){
$context_tree[ $row["nid"] ] = array();
|
|
Drupal DB Query to find Children (Recursively) |
|
|
EDIT
|
113 |
<ul class="item-list">
<?php
$terms_nood = taxonomy_node_get_terms_by_vocabulary($node,6);
$terms = taxonomy_get_tree(6);
foreach($terms as $term){
//$tagged = taxonomy_term_count_nodes($term->tid);
if( $term->name == arg(1) || array_key_exists( $term->tid,$terms_nood ) ){
echo("<li class=\"collapsed tag-category-".$popularityCategory."\">");
echo("<a href=\"/visual/".$term->name."\" class=\"active\">".$term->name."</a>");
echo("</li>\n");
}
}
?>
</ul>
|
|
Similar by Taxonomy |
|
|
EDIT
|
112 |
|
|
Wordpress |
|
|
EDIT
|
111 |
<?php
$fields = array(
'field_inspirational_imagery' => 'field_images',
);
// Loop through each of the fields/tables with the old name and change them
foreach($fields as $field_name => $new_field_name) {
// First check that field_name exists
if(!db_table_exists('field_data_' . $field_name)) {
// If we cannot find a data table then just continue.
continue;
}
// Define some things...
$data_table_name = 'field_data_' . $field_name;
$revision_table_name = 'field_revision_' . $f
|
|
Rename stuck field names |
|
|
EDIT
|
110 |
add line to /etc/hosts
127.0.0.1 amniot.localhost
add lines to /etc/apache2/httpd.conf
NameVirtualHost 127.0.0.1:80
<VirtualHost amniot.localhost:80>
<Directory "/Library/Webserver/Documents_AMNIOT">
Options FollowSymLinks Indexes
AllowOverride All
Order deny,allow
allow from All
</Directory>
ServerName amniot.localhost
DocumentRoot "/Library/Webserver/Documents_AMNIOT"
</VirtualHost>
|
|
OSX Virtual Web Host Config |
|
|
EDIT
|
109 |
add export PATH=$PATH:/usr/local/mysql/bin to ~/.bash_profile or /etc/profile
Backup database to text file
mysqldump database_name > database_name.sql
Remove database
mysql> drop database database_name;
Create database
mysql> CREATE DATABASE database_name;
|
|
MySQL Basics |
|
|
EDIT
|
108 |
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
require_once DRUPAL_ROOT . '/includes/password.inc';
if (isset($_GET['pass']) && !empty($_GET['pass'])) {
$newhash = user_hash_password($_GET['pass']);
}
else {
die('Retry with ?pass=PASSWORD set in the URL');
}
$updatepass = db_update('users')
->fields(array(
'pass' => $newhash,
// Uncomment the following lines to reset the administrative username and/or email address, if nec
|
|
Manually reset Drupal admin password |
|
|
EDIT
|
106 |
|
|
PHP |
|
|
EDIT
|
105 |
|
|
JQuery |
|
|
EDIT
|
104 |
<?php
function get_species_country($id_country) {
$inner = new EntityFieldQuery();
$inner_r = $inner->entityCondition('entity_type', 'field_collection_item')
->fieldCondition('field_species_country', 'target_id', $id_country, '=')
->execute();
if(!empty($inner_r['field_collection_item'])) {
$keys = array_keys($inner_r['field_collection_item']);
$query = new EntityFieldQuery();
$species_r = $query->entityCondition('entity_type', 'node')
|
|
Nested-query approach to mining field_collection data and relationship |
|
|
EDIT
|
103 |
<?php
symlink('/homepages/21/d93015512/htdocs/library/organic_connectivity',
'/homepages/21/d93015512/htdocs/drupal/sites/all/modules/organic_connectivity/lib');
?>
|
|
Create symlinks |
|
|
EDIT
|
102 |
|
|
Trauma Informed Care |
|
|
EDIT
|
101 |
Show Links Menu w/Active Class
<nav>
<?php $args=array(
'sort_order' => 'ASC',
'sort_column' => 'post_date',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'child_of' => 0,
'parent' => -1,
'exclude_tree' => '',
'number' => '',
'offset' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$pages = get_pages($args);
$current_id = get_the_ID();
if( $pages ){
echo( "<ul>\n" );
fore
|
|
Various WP snippets |
|
|
EDIT
|
100 |
<?php
$page_menu_items = menu_tree_output(menu_tree_all_data("main-menu"));
echo( drupal_render($page_menu_items) );
?>
|
|
Output a menu |
|
|
EDIT
|
99 |
<?php
$host = "127.0.0.1:10389";
$ldap = ldap_connect($host);
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
$username = "uid=admin,ou=system";
$password = "secret";
if( $bind = ldap_bind($ldap, $username, $password) )
echo( "logged into ".$host." as ".$username );
else
echo( "Fail" );
?>
|
|
LDAP Connect and Bind Test |
|
|
EDIT
|
98 |
contenttypetest.info
name = Contenttype test
description = Test - how can I create a new content type with hook form?
core = 7.x
files[] = contenttypetest.module;
files[] = contenttypetest.install;
contenttypetest.module
<?php
// hook_form implementation
function contenttypetest_form($node, &$form_state) {
$form = array();
$form['contenttypetest_pass'] = array(
'#type' => 'password',
'#title' => t('Type a password'),
'#description' => t('You can type
|
|
Create custom content type |
|
|
EDIT
|
97 |
<?php
$request = explode( "/", $_SERVER["REQUEST_URI"] );
array_shift( $request );
print_r( $requests );
?>
|
|
Fill array with server request URI strings |
|
|
EDIT
|
96 |
echo( "<img src=\"".image_style_url("thumbnail", $photo["uri"] )."\" alt=\"\"/>" );
|
|
Render imagecache images |
|
|
EDIT
|
95 |
<?php
function HOOK_menu_link( array $variables ){
$element = $variables['element'];
$sub_menu = '';
$name_id = strtolower(strip_tags($element['#title']));
// remove colons and anything past colons
if (strpos($name_id, ':')) $name_id = substr ($name_id, 0, strpos($name_id, ':'));
//Preserve alphanumerics, everything else goes away
$pattern = '/[^a-z]+/ ';
$name_id = preg_replace($pattern, '', $name_id);
$element['#attributes']['id'][] = 'menu-' . $element['#original_link']['mlid'] . ' '.$name_
|
|
Add unique IDs to menu items |
|
|
EDIT
|
94 |
function obtain_entities_by_type($entity_type,$bundle,$limit=10,$offset=0,$subject_nid=FALSE){
$query=new EntityFieldQuery();
$query->entityCondition('entity_type', $entity_type)
->entityCondition('bundle', $bundle)
->propertyCondition('status', 1)
->range($offset, $limit);
if($subject_nid)
$query->fieldCondition('field_subject','nid',$subject_nid);
$results=$query->execute();
if(array_key_exists('node',$results))
return entity_load($entity_type,array_k
|
|
Obtain matching entities |
|
|
EDIT
|
93 |
function HOOK_form_alter( &$form, &$form_state, $form_id ){
if( $form_id == "user_register_form" || $form_id == "user_profile_form" ) {
// Shows OTHER text field when 'Other' is selected as their specialty
$form["field_specialty_other"]["#states"] = array(
"visible" => array(
':input[name="field_specialty[und]"]' => array("value"=>"Other"),
)
);
}
}
|
|
Show field when a different selection is made on the same form |
|
|
EDIT
|
92 |
<?php
function HOOK_user_insert( &$edit, &$account, $category = NULL ){
// Don't create a new username if one is already set
if( strpos($account->name, 'temporary_') !== 0)
return;
// Otherwise, replace username with email address field
db_update("users")
->fields(array("name" => $edit["mail"]))
->condition("uid", $account->uid)
->execute();
$edit["name"] = $edit["mail"];
$account->name = $edit["mail"];
return;
}
function HOOK_user_register_form_alter( &am
|
|
Insert email as username at registration |
|
|
EDIT
|
91 |
<?php
function HOOK_user_login_submit( $form, &$form_state ){
$form_state["redirect"] = "";
}
function HOOK_form_user_login_alter( &$form, $form_state ){
$form["#submit"][] = "HOOK_user_login_submit";
}
?>
|
|
Login redirect |
|
|
EDIT
|
90 |
So other modules don't supersede your module, run this code once.
<?php
db_query("UPDATE {system} SET weight = 100 WHERE name = 'MODULE_NAME'");
?>
|
|
Make Drupal Module Most Important |
|
|
EDIT
|
89 |
.box img{
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'>
<filter id=\'grayscale\'>
<feColorMatrix type=\'saturate\' values=\'0.5\'/>
</filter>
</svg>#grayscale");
filter: gray alpha(opacity=50);
-webkit-filter: grayscale(50%);
-webkit-transform: translateZ(0);
}
.box img:hover{
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'>
<filter id=\'grayscale\'>
<feColorMatrix type=\'saturate\' values=\'1\'/>
</fi
|
|
Image Desaturation Effect |
|
|
EDIT
|
88 |
HTML
<div id="photos_rotator">
<ul>
<li>
<a href="/node/15">
<span class="title">003</span>
</a>
<div class="rotator_full"><img src="003_0.jpg" alt=""/></div>
</li>
<li>
<a href="/node/14">
<span class="title">002</span>
</a>
<div class="rotator_full"><img src="002_0.jpg" alt=""/></div>
</li>
<li>
<a href="/node/13">
<span class="title">001</span>
|
|
Slideshow |
|
|
EDIT
|
87 |
HTML
<img src="http://orgnsm.org/camoff.jpg" alt="Webcam" id="webcamImage"/></div>
JavaScript
function refreshCam(id, file) {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
document.getElementById(id).src = file + "?time="+h+m+s;
setTimeout('refreshCam("webcamImage","'+file+'")',10000);
}
window.onload = function(){
if( document.getElementById("webcamImage") )
refreshCam( "webcamImage","http://orgnsm.org/webcam.jpg" );
}
|
|
Webcam Image Refresher |
|
|
EDIT
|
85 |
w/JavaScript
//the callback function run after loading JSONp below
function test_results_loaded(data){
//post data to a service via ajax
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://orgnsm@orgnsm.org:lkAGWUE01H@orgnsm.testrail.com//index.php?/api/v2/add_result/1", true);
xhr.setRequestHeader('Content-Type', 'application/json;');
xhr.setRequestHeader('Accept', 'application/json;');
// send the collected data as JSON
xhr.send(JSON.stringify({"status_id":"1"}));
xhr.onloadend = function () { alert("Wrote test data
|
|
AJAX Remote Read, Local Write |
|
|
EDIT
|
84 |
w/JavaScript
window.onload = function(){
//create new button
var btn = document.createElement("a");
btn.setAttribute("id", "addedbutton");
var btntxt = document.createTextNode("Run Me");
btn.appendChild(btntxt);
//inject new button
document.getElementById("sidebar").appendChild(btn);
//add event to new button
document.getElementById('addedbutton').onclick = function(){
alert("Success");
}
}
w/JQuery
$(document).ready(function(){
var test = $("<a href='#'>Run Me</a>").click(function(){
a
|
|
DOM Inject and Add Event |
|
|
EDIT
|
82 |
<?php
$items = array(
0 => array( "item 1", "2013-09-13", "1" ),
1 => array( "item 2", "2013-09-14", "2" ),
2 => array( "item 3", "2013-09-15", "3" ),
);
######## CALCULATIONS #########
# set per-page var
if (isset($_GET["perpage"])) $perpage = $_GET["perpage"];
else $perpage = 10;
# calc numb of pages
$pages = ceil(count($items) / $perpage);
# which page are we on?
if( isset($_GET["page"]) && round($_GET["page"]) <= $pages && round($_GET["page"]) > 0 )
$page = round($_GET["page"]);
else $page = 1;
|
|
Pagination Logic |
|
|
EDIT
|
81 |
HTML
<meta name="viewport" content="width=device-width, initial-scale=1.0;"/>
CSS
@media (max-width: 480px){
}
@media (max-width: 767px){
#container{
padding: 0 25px;
}
nav ul li a{
font-size: 100%;
padding: 15px 0;
border-radius: 30px;
}
nav ul li a svg{
width: 60px;
height: 60px;
}
}
@media (min-width: 768px) and (max-width: 979px){
#container{
padding: 0 35px;
}
nav ul li a{
font-size: 120%;
padding: 20px
|
|
Device-Responsive Layout |
|
|
EDIT
|
80 |
The JavaScript
jQuery(function($){
$("#contact").submit(function(){
//grab form values before blowing it out of the DOM in the next line
values=$(this).serialize();
$("#contact").html( "<p>Sending message...</p>\n" );
//send the values to the PHP handler
$.ajax({
type: "POST",
url: $("#contact").attr('action'),
data: values,
success: function(re){
$("#contact").html(re);
}
});
return fal
|
|
Dynamic Form Submission |
|
|
EDIT
|
79 |
<?php
function getRSS( $url ){
$cobj = curl_init( $url );
curl_setopt( $cobj, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $cobj, CURLOPT_CONNECTTIMEOUT, 0 );//0 = no timeout
$tumblr_raw = curl_exec( $cobj );
curl_close( $cobj );
if( $tumblr_raw ){
$tumblr_xml = new DOMDocument();
$tumblr_xml->loadXML( $tumblr_raw );
//echo( "<pre>".$tumblr_xml->saveHTML()."</pre>" );
if( $tumblr_xml->getElementsByTagName("item") instanceof DOMNodeList &&
$tumblr_xml->getElementsByTagName("item")->ite
|
|
Read and Process RSS |
|
|
EDIT
|
5 |
|
|
La Picolla Scolla Italia |
|
|
EDIT
|
7 |
|
|
Incubator |
|
|
EDIT
|
69 |
|
|
Jellyfish Frequency |
|
|
EDIT
|
66 |
|
|
Attributes |
|
|
EDIT
|
53 |
|
|
Page Layout Method |
|
|
EDIT
|
52 |
Style Links HTML
<link rel="alternate stylesheet" type="text/css" href="/theme/KATALOG/style.css" title="KATALOG"/>
<link rel="alternate stylesheet" type="text/css" href="/theme/SCREEN/style.css" title="SCREEN"/>
<link rel="alternate stylesheet" type="text/css" href="/theme/spaecial/style.css" title="spaecial"/>
<link rel="alternate stylesheet" type="text/css" href="/theme/touchpanel/style.css" title="touchpanel"/>
<link rel="stylesheet" type="text/css" href="/theme/blawk/styl
|
|
Stylesheet Switcher |
|
|
EDIT
|
14 |
|
|
BossaNova Robotics |
|
|
EDIT
|
83 |
|
|
TiedyeJohn |
|
|
EDIT
|
20 |
|
|
Kimochis Portal |
|
|
EDIT
|
41 |
|
|
Frameworks |
|
|
EDIT
|
15 |
|
|
IAS |
|
|
EDIT
|
10 |
|
|
PaulBird.tv |
|
|
EDIT
|
72 |
|
|
777 |
|
|
EDIT
|
73 |
|
|
Organic Interfaces |
|
|
EDIT
|
70 |
|
|
Luscious Hawaiian |
|
|
EDIT
|
16 |
|
|
N.i. Portfolio |
|
|
EDIT
|
77 |
|
|
Visionary Sports Group |
|
|
EDIT
|
39 |
|
|
Interactivity |
|
|
EDIT
|
38 |
|
|
Layout & Typography |
|
|
EDIT
|
37 |
|
|
Content Strategy |
|
|
EDIT
|
9 |
|
|
RosaPharma |
|
|
EDIT
|
107 |
|
|
Ouroboros |
|
|
EDIT
|
18 |
|
|
Business Researchers |
|
|
EDIT
|
32 |
|
|
Drupal |
|
|
EDIT
|
26 |
|
|
Radiesse |
|
|
EDIT
|
25 |
|
|
Process |
|
|
EDIT
|
24 |
|
|
FlipVideo |
|
|
EDIT
|
17 |
|
|
N.i. Extranet |
|
|
EDIT
|
12 |
|
|
Resumé |
|
|
EDIT
|
11 |
|
|
Disciplines |
|
|
EDIT
|
13 |
|
|
Code |
|
|
EDIT
|
4 |
|
|
Graphic Design |
|
|
EDIT
|
3 |
|
|
JavaScript |
|
|
EDIT
|
2 |
|
|
Stylesheet Coding |
|
|
EDIT
|
123 |
|
|
Information Structuring |
|
|
EDIT
|
6 |
|
|
Template Coding |
|
|
EDIT
|
76 |
|
|
Amniot |
|
|
EDIT
|
58 |
|
|
FlipVideo - Store |
|
|
EDIT
|
47 |
|
|
Organic Planner |
|
|
EDIT
|
46 |
|
|
Triple Goddess |
|
|
EDIT
|
30 |
|
|
LiamShy |
|
|
EDIT
|
44 |
|
|
Cytel |
|
|
EDIT
|
42 |
|
|
Sightspeed - Corporate |
|
|
EDIT
|
23 |
|
|
Breze |
|
|
EDIT
|
57 |
|
|
Damiak |
|
|
EDIT
|
75 |
|
|
FÅ“tus |
|
|
EDIT
|
63 |
|
|
Aaron Metals |
|
|
EDIT
|
22 |
|
|
Types |
|
|
EDIT
|
8 |
|
|
Work |
|
|
EDIT
|
64 |
|
|
Medical Industries America, Inc. |
|
|
EDIT
|
118 |
|
|
Recent |
|
|
EDIT
|