Skip to content

Instantly share code, notes, and snippets.

View ckidow's full-sized avatar

Christian Kipke ckidow

View GitHub Profile
<?php
$foo = NULL;
var_dump(isset($foo));
var_dump(isset($bar));
// gibt in beiden Fällsen "false" zurück
<?php
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['my_vid'] = BaseFieldDefinition::create('integer')
uuid: fb63811a-5555-4101-97ae-de49656cf585
langcode: de
status: true
dependencies:
config:
- image.style.thumbnail
module:
- image
- media
- user
$form['foobar'] = array(
'#type' => 'select',
'#title' => t('FooBar'),
'#options' => array(
'foo' => t('Foo),
'bar' => t('Bar),
),
'#default_value' => 'foo',
'#value' => 'bar',
);
@ckidow
ckidow / mymodule.module
Last active June 2, 2016 07:02
Ajax submit only on default origin submit button...
<?php
function mymodule_form_alter(&$form, &$form_state, $form_id) {
switch($form_id) {
case 'views_exposed_form':
$form['additional_buttons'] = array(
'#type' => 'fieldset',
'#collapsible' => FALSE,
'#printed' => TRUE,
);
@ckidow
ckidow / nodes_without_images.php
Created March 15, 2016 12:40
I need nodes where file field "field_images" is empty
<?php
// I need nodes where file field "field_images" is empty
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->entityCondition('bundle', 'real_estate')
->fieldCondition('field_images', 'fid', 'NULL', '=')
->addMetaData('account', user_load(1)); // Run the query as user 1.
@ckidow
ckidow / template.php
Last active August 29, 2015 14:15
Drupal: Render a subtree of a menu by PARENT menu item id
// This is not a hook - it's a custom function'
function THEMENAME_childtree($mlid, $menu='main-menu') {
$tree = menu_tree_all_data($menu);
foreach($tree as $child){
if($child['link']['mlid'] == $mlid){
return drupal_render(menu_tree_output($child['below']));
}
}
}