Skip to content

Instantly share code, notes, and snippets.

View BramEsposito's full-sized avatar
🌊

Bram Esposito BramEsposito

🌊
View GitHub Profile
@BramEsposito
BramEsposito / drupal_fields_from_entity.php
Last active December 10, 2015 08:08
Drupal: get field items from entity
<?php
$items = field_get_items('node', $node, 'field_yourfield', $node->language);
@BramEsposito
BramEsposito / drupal_custom_views.php
Last active December 10, 2015 08:08
Drupal: Embed a view with custom parameters. (works in node body with PHP text format == dirty hack)
<?php
$display_id = "departement";
$args = array("view argument");
$view = views_get_view('view machine name');
$view->items_per_page = 0; // set number of items per page. 0 is all.
$content = $view->execute_display($display_id, $args);
print($content['content']);
@BramEsposito
BramEsposito / drupal_message_to_admin.php
Created December 29, 2012 08:33
Display a message to a Drupal administrator only
<?php
if(user_access('administer')) {
drupal_set_message("hello Admin!");
}
@BramEsposito
BramEsposito / ping.php
Created February 13, 2015 09:46
PHP Pinger
<?php
// from: http://stackoverflow.com/questions/7372780/creating-a-ping-uptime-service-with-php
// TODO: add string recognition to check specific pages
//Config information
$email = "[email protected]";
$server = "google.com"; //the address to test, without the "http://"
@BramEsposito
BramEsposito / enable-drush-debugging.sh
Created January 21, 2016 08:29
How to enable Drush debugging
export PHP_OPTIONS="-dxdebug.remote_autostart=On -didekey=PHPSTORM -dremote_host=localhost -dprofiler_enable=1"
@BramEsposito
BramEsposito / enable-drush-debugging.sh
Last active February 16, 2018 08:42
How to enable Drush debugging on MAMP
# set the correct php.ini for drush!
export PHPRC='/Library/Application Support/appsolute/MAMP PRO/conf/'
export PHP_OPTIONS="-dxdebug.remote_autostart=On -didekey=PHPSTORM -dremote_host=localhost -dprofiler_enable=1"
# FROM https://www.deeson.co.uk/labs/debugging-drupal-drush-real-time-phpstorm-and-xdebug
@BramEsposito
BramEsposito / drush_phpinfo.sh
Created January 21, 2016 11:11
get php_info for the drush process
# get information over the php version (php_info)
drush php-eval "phpinfo();" | less
@BramEsposito
BramEsposito / .gitignore
Created March 21, 2016 10:12 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@BramEsposito
BramEsposito / optimize.php
Last active May 26, 2016 12:34
Optimize your images when uploaded with IMCE
<?php
/**
* You need to have module imageapi_optimize enabled
*/
function HOOK_file_presave($file) {
// only temporary files from IMCE
if ($file->source === 'imce' && $file->status == 0) {
if ($wrapper = file_stream_wrapper_get_instance_by_uri($file->uri)) {