Skip to content

Instantly share code, notes, and snippets.

View isramv's full-sized avatar
🐧

Israel M isramv

🐧
View GitHub Profile
@isramv
isramv / example.twig
Created February 10, 2023 16:11
How to check if a multiple paragraph is empty
{% set preprinted_supplies = node.field_issue_calendar.value %}
{% set preprinted_supplies_not_empty = [] %}
{% for item in preprinted_supplies %}
{% set psp = drupal_field('field_preprinted_supplied_pieces', 'paragraph', item.target_id) %}
{% if psp['#title'] is not null %}
{% set preprinted_supplies_not_empty = preprinted_supplies_not_empty|merge(['true']) %}
{% endif %}
{% endfor %}
{% if preprinted_supplies_not_empty|length > 0 %}
@isramv
isramv / custom.theme
Created February 10, 2023 15:05
Remove the word "Front |" from the homepage Drupal 9
function custom_theme_preprocess_html(&$vars) {
$vars['is_front'] = \Drupal::service('path.matcher')->isFrontPage();
}
@isramv
isramv / autofix.md
Last active October 8, 2020 15:45
stylelint implementation.

Fixing property sort order:

  • node ./node_modules/stylelint/bin/stylelint.js assets/styles/*.scss --fix
  • node ./node_modules/stylelint/bin/stylelint.js assets/styles/**/*.scss --fix
{
  "plugins": [
  "stylelint-order"
 ],
@isramv
isramv / gatsby-node.js
Created May 28, 2020 18:21
gatsby-node.js
exports.onCreateNode = ({node, actions, getNodes, graphql, createNodeId, getCache}) => {
if (node.internal.type !== 'SitePage') {
return;
}
const {
createNode
} = actions
let media = []
@isramv
isramv / how_to_create_global_gitignore.md
Last active December 11, 2019 18:21
Create a global gitignore file.

Create the global gitignore.

$ touch .gitignore_global

let git know where your global ignore file is located at.

$ git config --global core.excludesfile ~/.gitignore_global

Drupal\geolocation\Plugin\Field\FieldType\GeolocationItem.php

public static function generateSampleValue(FieldDefinitionInterface $field_definition) {

  // Guadalajara.
  $longitude = (float) -103.3496;
  $latitude = (float) 20.6597;
  $radius = rand(1,5); // in miles
@isramv
isramv / drupal toolbar die
Created March 12, 2019 22:26
originally from @arshad
/* eslint-disable */
(function ($) {
Drupal.behaviors.dieToolbardie = {
attach: function (context) {
window.matchMedia('(min-width: 975px)').addListener( function(event) {
event.matches ? $('#toolbar-item-administration', context).click() : $('.toolbar-item.is-active', context).click();
});
}
};
})(jQuery);
@isramv
isramv / nav-touch.js
Created March 7, 2019 21:53
css drowpdown navigation on touch enabled devices.
/* eslint-disable */
(function ($) {
Drupal.behaviors.mainNavTouch = {
attach: function (context) {
if (Modernizr.touchevents) {
$('#block-evolve-main-menu > ul.menu > li.expandable > a:not(.ohm-mobile-toggle)', context).on('click', function(event) {
var element = $(this);
var firstTimeout = setTimeout(function() {
@isramv
isramv / sticky.js
Created February 5, 2019 19:43
sticky nav in discoverla
// Sticky navigation.
var navbar = $("#navbar");
var stickyClass = "sticky";
var offsetTop = $('#navbar').offset();
$(window, context).scroll(function() {
if ( $(this).scrollTop() > offsetTop.top ) {
navbar.addClass(stickyClass);
$('#dla-main-content').css('margin-top', navbar.height());
} else if ( $(this).scrollTop() < navbar.height() ) {
@isramv
isramv / node-templates-d8.md
Created November 9, 2018 23:04
Working with node templates drupal 8

working with node templates.

{% set nodeTitle = node.get('title') %}