Skip to content

Instantly share code, notes, and snippets.

View suresh-kumara-gist's full-sized avatar

Suresh kumara suresh-kumara-gist

View GitHub Profile
@suresh-kumara-gist
suresh-kumara-gist / delete menu items.
Created November 18, 2017 07:19
delete menu items.
ini_set('memory_limit','3000M');
// replace menu_name "main" to some other menu
entity_delete_multiple('menu_link_content', \Drupal::entityQuery('menu_link_content')
->condition("menu_name", "main", "=")->execute());
@suresh-kumara-gist
suresh-kumara-gist / update menu item parent
Created November 18, 2017 07:14
update menu item parent and weight
/**
* @param string $linkuri
* @param string $menuname
* @return Drupal\menu_link_content\Entity\MenuLinkContent
* An array of menu link content objects
*/
function getMenuLinkContent($linkuri, $menuname) {
return \Drupal::entityTypeManager()->getStorage('menu_link_content')->loadByProperties(
[
@suresh-kumara-gist
suresh-kumara-gist / how to load remote js in drupal 8
Created November 7, 2017 16:33
how to load remote js in drupal 8
braintree-hosted-fields:
remote: https://github.com/braintree/braintree-web
version: "3.19.1"
license:
name: MIT
url: https://github.com/braintree/braintree-web/blob/3.19.1/LICENSE
gpl-compatible: true
js:
"https://js.braintreegateway.com/web/3.19.1/js/hosted-fields.min.js": { minified: true }
dependencies:
git remote -v
to add upstream url:
git remote add upstream https://gitlab.test.de/drupal/website.git
to modify upstream url:
git remote set-url upstream https://gitlab.test.de/sureshk/website.git
@suresh-kumara-gist
suresh-kumara-gist / create add conact form link in drupal 8
Created October 19, 2017 17:54
create add conact form link in drupal 8
@suresh-kumara-gist
suresh-kumara-gist / drupal 8 address field fetch city
Created October 17, 2017 09:38
drupal 8 address field fetch city
change node__field_location to your address field table name , column name also
$query = \Drupal::database()->select('node__field_location', 'fa');
$query->fields('fa', ['field_location_locality']);
$query->condition('bundle', 'venture');
// $query->condition('field_location_locality', '', 'like');
// $query->condition('field_location_country_code', '');
$query->distinct();
$query->orderBy('field_location_locality');
$courseRatings = $query->execute()->fetchAll(\PDO::FETCH_ASSOC);
@suresh-kumara-gist
suresh-kumara-gist / jQuery table td data
Created October 1, 2017 16:34
jQuery table td data
var cellText = "composer require "; jQuery("#edit-missing-module-list > tbody > tr > td:nth-child(1)").each(function() {
var cellText2 = jQuery(this).html(); cellText += ' drupal/' + cellText2;
}); jQuery('#system-breadcrumb').text(cellText);
@suresh-kumara-gist
suresh-kumara-gist / Drupal 8 database query debug
Created September 28, 2017 11:40
Drupal 8 database query debug
echo '<pre>' ;print_r( $query->conditions());
echo '<pre>' ; print_r($result->getQueryString()); exit;
@suresh-kumara-gist
suresh-kumara-gist / Drupal 8 render service, list item , markup create
Created September 19, 2017 11:15
Drupal 8 render service, list item , markup create
$user_list[] = "$user->name ($user->mail) last active on " .
\Drupal::service('date.formatter')->format($user->access, 'long');
$data = ['#theme'=>'item_list','#type'=>'ul','#items'=>$user_list];
$user_list = \Drupal::service('renderer')->renderRoot($data);
\Drupal\Core\Render\Markup::create();
@suresh-kumara-gist
suresh-kumara-gist / Jquery select all checkboxes
Created September 14, 2017 10:01
Jquery select all checkboxes
jQuery('input:checkbox').attr("checked", "checked");