Skip to content

Instantly share code, notes, and snippets.

View edutrul's full-sized avatar
💭
Changing the world

Eduardo Telaya edutrul

💭
Changing the world
View GitHub Profile
@edutrul
edutrul / sandwich_sandwich.info.yml
Created March 14, 2018 15:34
This is an example on how to create a custom plugin type and create plugin instances. This contains - Plugin type (Cheese) - The plugin type is Manager(who controlls all below:) - It has Annovation discovery - It has an interface to declare methods - It has an asbtract base class which will be as a kick starter for all plugin instances. - 2 plug…
name: 'sandwich'
type: module
description: 'Example plugin type'
core: 8.x
package: 'Custom'
@edutrul
edutrul / pull.sh
Created February 13, 2018 16:11
AUTOMATIC PULL
#!/bin/bash
while true
do
cd ~/projects/XXX/ && git pull origin master
sleep 60
done
@edutrul
edutrul / mymodule.css
Created December 24, 2017 18:05 — forked from AlexSkrypnyk/mymodule.css
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@edutrul
edutrul / mymodule.css
Created December 24, 2017 18:05 — forked from AlexSkrypnyk/mymodule.css
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@edutrul
edutrul / module_name.install
Created November 24, 2017 19:30 — forked from jmolivas/module_name.install
Update field data table and configuration storage object.
<?php
/**
* Update field data table and configuration storage
*/
function _update_field_data(
$entityType,
$field,
$valueMapping,
@edutrul
edutrul / php-geocode.php
Last active October 6, 2017 04:40
php-geocode from php library kamranahmedse - here code snippet
<?php
// Introduce the class into your scope.
use KamranAhmed\Geocode\Geocode;
// Optionally you can pass the API key for Geocoding.
$geocode = new Geocode();
// Get the details for the passed address.
@edutrul
edutrul / convert-integer-to-roman.php
Created September 8, 2017 16:26
How to convert integer to Roman number
<?php
/**
* Converts integer to Roman.
*
* @param int $integer
* Integer to be converted to Roman string.
*
* @return string
*/
public function integerToRoman($integer) {
@edutrul
edutrul / mymodule.php
Last active July 30, 2017 05:45
Implement STATES on drupal8
<?php
$formIds = [
'node_location_form',
'node_location_edit_form',
];
if (in_array($form_id, $formIds)) {
$form['#attached']['library'][] = 'care_location/care_location_node_form';
$form['field_location_google_streetview']['#states'] = [
'visible' => [
':input[name="field_location_what_to_display"]' => ['value' => 'field_location_google_streetview'],
@edutrul
edutrul / README--for-adding-custom-class-to-ckeditor.md
Last active July 3, 2017 15:52
How to add a custom class to ckeditor in drupal8
  1. Open format editor of your preference admin/config/content/formats/manage/basic_html
  2. Add styles BUTTON (Drag and drop)
  3. A new tab will be created "Styles Dropdown"
  4. Click on "Styles Dropdown" tab
  5. Add ul.two-column--list|Two column list
  6. (HIGHLY IMPORTANT) if you have have "Limit allowed HTML tags and correct faulty HTML" then Make sure
      is added, IF NOT PLEASE add it.
    • Save it!
    • Add ul.two-column--list { columns: 2; } in your current theme. Ckeditor automatically will find it.
    • Now create a content and locate on a textarea formatter field
@edutrul
edutrul / ShipPackageFlowForm.php
Created June 26, 2017 02:45
Create new form element(Dropdown) in drupal 8 ajax and set image from taxonomy term
<?php
namespace Drupal\ship_package\Form;
use Drupal\Core\Url;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;