Skip to content

Instantly share code, notes, and snippets.

View jcicero518's full-sized avatar

Jeff Cicero jcicero518

View GitHub Profile
@jcicero518
jcicero518 / drupal-test-csv.php
Created April 20, 2022 21:34 — forked from mecmartini/drupal-test-csv.php
Drupal - Test CSV
<?php
namespace Drupal\Tests\tablefield\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Simple test to ensure that a field can be created.
*
* @group tablefield
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$id = $items->getEntity()->id();
# Generate a wrapper to use as dom root to attach the React component.
$field_name = $this->fieldDefinition->getItemDefinition()->getFieldDefinition()->getName();
$wrapper_id = 'drupal-and-react-app-' . $field_name .'-'. $id;
@jcicero518
jcicero518 / remove_view_duplicates.includes.php
Created March 30, 2022 18:14 — forked from mattschaff/remove_view_duplicates.includes.php
Drupal 8: Remove duplicate records in view
<?php
/**
* Implements hook_preprocess_views_view
*/
function my_module_preprocess_views_view(&$vars){
// Only use unique IDs for view.
// Use this code for views with Better Exposed Filters.
if ($vars['view']->id() === 'view_name_bef') {
$rows = [];
@jcicero518
jcicero518 / custom-nav-walker-usage.php
Created November 11, 2020 17:12 — forked from kosinix/custom-nav-walker-usage.php
WordPress: Using a custom nav walker to create navigation menus in plain <a> tags. That is the <ul> and <li> tags are not present. Very useful if you want to create simple links that can be centered with a simple text-align:center on the containing element.
<?php
// In your template files like footer.php
// The items_wrap value ('%3$s') removes the wrapping <ul>, while the custom walker (Nav_Footer_Walker) removes the <li>'s.
wp_nav_menu(array('items_wrap'=> '%3$s', 'walker' => new Nav_Footer_Walker(), 'container'=>false, 'menu_class' => '', 'theme_location'=>'footer', 'fallback_cb'=>false ));
?>
@jcicero518
jcicero518 / _bootstrap_bulma_helpers.scss
Created September 8, 2020 17:21 — forked from wrabit/_bootstrap_bulma_helpers.scss
Bootstrap style responsive helper utilities for Bulma
/*
Start Bootstrap style responsive spacer helper
Utilities for spacing, text and float
*/
$spacer: 1rem !default;
$spacers: () !default;
$spacers: map-merge((
@jcicero518
jcicero518 / settings.local.php
Created August 31, 2020 20:17 — forked from keopx/settings.local.php
Drupal 8 Redis settings.local.php
<?php
/**
* Set redis configuration.
*/
/** @see: https://docs.platform.sh/frameworks/drupal8/redis.html */
if (extension_loaded('redis')) {
// Set Redis as the default backend for any cache bin not otherwise specified.
// $settings['cache']['default'] = 'cache.backend.redis';
@jcicero518
jcicero518 / BetterRestSerializer.php
Created July 29, 2020 01:39 — forked from daggerhart/BetterRestSerializer.php
Drupal 8 views style plugin for a better rest serializer.
<?php
namespace Drupal\my_module\Plugin\views\style;
use Drupal\rest\Plugin\views\style\Serializer;
/**
* The style plugin for serialized output formats.
*
* @ingroup views_style_plugins
@jcicero518
jcicero518 / ViewsSerializerCount.php
Last active July 29, 2020 01:24
Drupal 8 Views Rest Serializer
<?php
namespace Drupal\my_module\Plugin\views\style;
use Drupal\Core\Annotation\Translation;
use Drupal\rest\Plugin\views\style\Serializer;
use Drupal\views\Annotation\ViewsStyle;
/**
* Class ViewsSerializerCount
@jcicero518
jcicero518 / referer.php
Created July 23, 2020 17:41 — forked from morsok/referer.php
Drupal 8 : Do something based on the referer if it's your website or another.
use Drupal\Core\Url;
use Symfony\Component\HttpFoundation\Request;
function my_function() {
$previousUrl = \Drupal::request()->server->get('HTTP_REFERER');
$fake_request = Request::create($previousUrl);
$url_object = \Drupal::service('path.validator')->getUrlIfValid($fake_request->getRequestUri());
if ($url_object) {
$route_name = $url_object->getRouteName();
// Do something with $route_name;
@jcicero518
jcicero518 / vanilla-fitvids.js
Created June 6, 2019 17:06 — forked from ebinion/vanilla-fitvids.js
FitVids ES6 & AMD ready
// Vanilla version of FitVids
// Still licencened under WTFPL
//
// Not as robust and fault tolerant as the jQuery version.
// And also, I don't support this at all whatsoever.
const vanillaFitVids = () => {
// List of Video Vendors embeds you want to support
const players = [
'iframe[src*="youtube.com"]',