This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function array2csv($array) { | |
$csv = fopen('php://temp/maxmemory:'. (5*1024*1024), 'r+'); | |
fputcsv($csv, $array, ';'); | |
rewind($csv); | |
return stream_get_contents($csv); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$path = current_path(); | |
$path_alias = drupal_lookup_path('alias', $path); | |
$patterns = '' . PHP_EOL . 'node/n' . PHP_EOL . 'blog/*'; | |
if (drupal_match_path($path, $patterns) || drupal_match_path($path_alias, $patterns)) { | |
// Do things. | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param tid | |
* Term ID | |
* @param child_count | |
* TRUE - Also count all nodes in child terms (if they exists) - Default | |
* FALSE - Count only nodes related to Term ID | |
* @param node_type | |
* Count only nodes of one type (string). | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Find taxonomy term (by name) limited by parent term. | |
* | |
* In many cases you may need to find children in exact term (parent). | |
* Here we do this in efficent way with precise query (not like taxonomy_get_tree() | |
* where all the terms loading. | |
* | |
* @param $name | |
* @param $parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Media queries breakpoints | |
// -------------------------------------------------- | |
// Extra small screen / phone | |
$screen-xs ?= 480px | |
$screen-phone ?= $screen-xs | |
// Small screen / tablet | |
$screen-sm ?= 768px | |
$screen-tablet ?= $screen-sm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Supabase credentials. Can be found in the settings of your project | |
const supaUrl = 'https://base-id.supabase.co' | |
const supaKey = 'public-key-hash' | |
/** | |
* Retrieve a row from table by its ID. | |
* | |
* @param {string} table Table where we're looking for our row. | |
* @param {string} id The ID of the row to retrieve. | |
* @returns {Promise<*|{}>} The row object with the given ID, or `undefined` if it was not found. |