Skip to content

Instantly share code, notes, and snippets.

View calvez's full-sized avatar
🏠
Working from home

calvez calvez

🏠
Working from home
  • Budapest, Hungary
View GitHub Profile
drush sql-dump --skip-tables-list=mgt_cache,mgt_cache_*,mgt_users, mgt_users_role, mgt_role_permission | gzip > $path/$db_name-$date.gz
split
split --bytes=50M mnet_files-20190111.tar.gz mnet0111
https://www.metaltoad.com/blog/drupal-8-entity-api-cheat-sheet
grep -r --include=*.php "fonts.googleapis.com"
Warning: Illegal offset type in isset or empty in _ds_field_ui_table_layouts() (line 720 of modules/contrib/ds/includes/field_ui.inc).

_ds_field_ui_table_layouts('media', 'image', 'default', Array, Object) (Line: 42)
ds_field_ui_fields_layouts(Array, Object) (Line: 247)
ds_form_entity_view_display_edit_form_alter(Array, Object, 'entity_view_display_edit_form') (Line: 539)
Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object, 'entity_view_display_edit_form') (Line: 834)
Drupal\Core\Form\FormBuilder->prepareForm('entity_view_display_edit_form', Array, Object) (Line: 276)
Drupal\Core\Form\FormBuilder->buildForm('entity_view_display_edit_form', Object) (Line: 93)

Drupal\Core\Controller\FormController->getContentResult(Object, Object)

@calvez
calvez / mgt
Created December 5, 2018 12:17
{
"protocol": "sftp",
"host": "10.10.10.10",
"port": 22,
"username": "user",
"remotePath": "/var/www/docroot/themes/custom/magnetbank",
"privateKeyPath": "~/.ssh/id_rsa",
"autoUpload": false,
"autoDelete": false,
"ignore": [
{% if user.hasPermission('administer nodes') %}
... do something
{% endif %}
Thanks to @hj for providing it.
Check if a user has a permission in Drupal Twig
2) How to print comments separate from fields in a node template
Print comment and comment form fields separately
This one was fun, for no other reason than I was up late having a bottle of beer on a Friday evening when my friend Preston So needed help printing comment fields in nodes (mid-afternoon his time). The specific request was to get the variable for a custom comment type that he wanted to print in a node template. After some late night (by European time zones) investigation, and kinting the hell out of {{ content ... }} I came up with a variable to show the custom comments and another to show the custom comment form.
An illegal choice has been detected. Please contact the site administrator.
Notice: Undefined index: #parents in Drupal\Core\Form\FormState->getError() (line 1112 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->getError(Array) (Line: 164)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 124)
@calvez
calvez / wp+woocommerce.nginx.conf
Last active October 16, 2018 11:32
zema nginx settings
server {
listen 443;
listen [::]:443;
keepalive_timeout 70;
ssl on;
ssl_certificate /var/www/html/zt.pem;
ssl_certificate_key /var/www/html/zt.key;
root /var/www/html/z.hu/docroot;
index index.php;
@calvez
calvez / wordpress.nginx
Created October 14, 2018 08:03 — forked from LeCoupa/wordpress.nginx
WordPress - Nginx Configuration File (with SSL) --> https://github.com/LeCoupa/awesome-cheatsheets
##
# @server studio
# @host hackisition.com
# @desc nginx host rules
# @author Julien Le Coupanec <[email protected]>
##
# HTTP Server
server {
listen 80;
// If the paragraph type has got a background color field.
if (isset($element['subform']['bp_background']) && isset($element['subform']['bp_background']['widget'])) {
$configFactory = \Drupal::configFactory()->getEditable('varbase_bootstrap_paragraphs.settings');
$background_colors = $configFactory->get('background_colors');
$background_colors_options = ['_none' => t('N/A')];
$lines = explode(PHP_EOL, $background_colors);
foreach($lines as $line) {
$line = explode('|', $line);
$background_colors_options[$line[0]] = $line[1];