Skip to content

Instantly share code, notes, and snippets.

@yanniboi
yanniboi / mini_panel.php
Last active August 29, 2015 13:59
Reverting ctools exportables
<?php
$panels_minis = array(
'panels_mini_name',
'panels_mini_name_1',
);
foreach ($panels_minis as $panels_mini_name) {
if ($panels_mini = panels_mini_load($panels_mini_name)) {
if ($panels_mini->export_type == EXPORT_IN_CODE + EXPORT_IN_DATABASE) {
panels_mini_delete($panels_mini);
@yanniboi
yanniboi / terminal.sh
Created April 10, 2014 08:50
Backup drupal files
tar zcvf files_backup.tar.gz sites/default/files --exclude 'sites/default/files/styles/*' --exclude 'sites/default/files/css/*' --exclude 'sites/default/files/js/*' --exclude 'sites/default/files/tmp/*'
@yanniboi
yanniboi / devel.php
Created December 16, 2013 12:58
User login link without drush
<?php
global $user;
dpm(user_pass_reset_url($user) . '/login');
@yanniboi
yanniboi / field_update_hook.php
Last active December 30, 2015 00:09
Code snippet for field creating update hook
<?php
/**
* Code snippet for field create update hook.
*/
function module_update_7001() {
$t = get_t();
$fields = array();
@yanniboi
yanniboi / instagram-block-image.html.twig
Created November 21, 2013 16:10
Writing a theme function and TWIG template for Instagram Block (drupal 8)
{#
/**
* @file
* Default theme implementation of an Instagram image link.
*
* Available variables:
* - data: The entire data array returned from the Instagram API request.
* - href: The url to the Instagram post page.
* - src: The source url to the instagram image.
* - width: The display width of the image.
@yanniboi
yanniboi / instagram-block-image.tpl.php
Created November 21, 2013 16:06
Writing a theme function and template for Instagram Block (drupal 7)
/**
* @file
* Default theme implementation of an Instagram image link.
*
* Available variables:
* - data: The entire data array returned from the Instagram API request.
* - href: The url to the Instagram post page.
* - src: The source url to the instagram image.
* - width: The display width of the image.
* - height: The display height of the image.
@yanniboi
yanniboi / InstagramBlockBlock.php
Last active February 14, 2018 17:49
Block Class for Instagram Block module (drupal 8)
/**
* @file
* Contains \Drupal\instagram_block\Plugin\Block\InstagramBlockBlock.
*/
namespace Drupal\instagram_block\Plugin\Block;
use Drupal\block\BlockBase;
use Drupal\block\Annotation\Block;
use Drupal\Core\Annotation\Translation;
instagram_block_admin_config_form:
path: '/admin/config/content/instagram_block'
defaults:
_form: 'Drupal\instagram_block\Form\InstagramBlockForm'
requirements:
_permission: 'administer site configuration'
@yanniboi
yanniboi / new.instagram_block.module
Last active December 29, 2015 00:09
Pages and Menu routing in Instagram Block (drupal-8)
function instagram_block_menu() {
$items['admin/config/content/instagram_block'] = array(
'title' => 'Instagram Block',
'description' => 'Configuration page for Instagram Block.',
'router_name' => 'instagram_block_admin_config_form',
);
return $items;
}
@yanniboi
yanniboi / InstagramBlockForm.php
Last active December 29, 2015 00:09
Form Class for Instagram Block module (drupal 8)
/**
* @file
* Contains \Drupal\instagram_block\Form\InstagramBlockForm.
*/
namespace Drupal\instagram_block\Form;
use Drupal\Core\Form\ConfigFormBase;
/**