Skip to content

Instantly share code, notes, and snippets.

@Bon2xl
Bon2xl / sdc-error.php
Created July 22, 2024 18:15
Drupal SDC Error
The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\Core\Utility\Error::logException() in Drupal\sdc\Twig\TwigComponentLoader->exists() (line 79 of modules/contrib/sdc/src/Twig/TwigComponentLoader.php).
// This error means that the template doesn't exists. Check the component name, sometimes your are calling in the different module/theme name ex. module_name:component_name.
@Bon2xl
Bon2xl / userModel.js
Created September 4, 2021 17:17
Joi validation and middleware
From: https://gist.github.com/stongo/6359042
Commented By: geraldanosike commented on Jul 24
// ********************************
// User Model
// ********************************
const mongoose = require('mongoose')
const Joi = require('joi')
const userSchema = new mongoose.Schema({
@Bon2xl
Bon2xl / get-url-param.js
Last active February 19, 2020 20:19
Get URL PARAM
if ($("body").hasClass("page-user-patron")) {
function urlParam(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if (results == null){
return null;
}
else {
return decodeURI(results[1]) || 0;
}
}
@Bon2xl
Bon2xl / firestore.js
Created September 28, 2019 21:39
Firestore Query
//**********************************************
// Get all documents
//**********************************************
router.get('/', async function(req, res, next) {
const title = 'Boozeyum';
let cityRef = await db.collection('cities');
const data = [];
let getDoc = await cityRef.get()
.then(snapshot => {
snapshot.docs.forEach(doc => {
@Bon2xl
Bon2xl / Directory
Last active April 30, 2019 13:08
Drupal 8 "News Articles" blocks plugin module
news_articles.info.yml
news_articles.libraries.yml
news_articles.module
const snapPromise = db.ref('bars')
.once('value')
const snap = await snapPromise
const value = snap.val()
// do something with value...
// same thing
const value = await db
.ref('bars')
@Bon2xl
Bon2xl / FormatTime.md
Created July 12, 2018 16:49
Format Time

Post and Get Time Format

TYPE: POST | GET

POST

Import moment timezone and lodash

import moment from 'moment-timezone';
import _ from 'lodash';
@Bon2xl
Bon2xl / render_block.php
Created April 28, 2017 17:55
Render block in Drupal
$block = module_invoke('hf_stacks_search', 'block_view', 'hf_stacks_search_block');
print render($block['content']);
@Bon2xl
Bon2xl / getthemename.php
Last active April 26, 2017 22:08
Drupal: get current theme
$custom_theme = variable_get('theme_default');
dpm($custom_theme);
@Bon2xl
Bon2xl / mapsInfoWindows.js
Created September 28, 2016 00:43
Google Maps multiple info windows
var center = new google.maps.LatLng(53.5557957,-113.6340293);
var options = {
'zoom': 9,
'center': center,
'mapTypeId': google.maps.MapTypeId.ROADMAP,
'disableDoubleClickZoom': false,
};
var map = new google.maps.Map(document.getElementById("map"), options);
var markers = [];
}