This file contains hidden or 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
window.SpeechRecognition = window.SpeechRecognition || window.webkitSpeechRecognition; | |
const recognition = new SpeechRecognition(); | |
recognition.interimResults = true; | |
recognition.addEventListener('result', e => { | |
transcript = Array.from(e.results).map(result => result[0]).map(result => result.transcript).join(''); | |
const statement = e.results[0][0].transcript; | |
console.log(statement); | |
if (statement === "voice admin new page") { |
This file contains hidden or 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
// Get all even no 1 to 100 | |
<?php | |
$i; | |
for($i=1;$i<=100;$i++) | |
{ | |
if($i%2==0) | |
{ | |
echo $i."<br>"; | |
} | |
} |
This file contains hidden or 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
https://riptutorial.com/ebook?q=&page=2 |
This file contains hidden or 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 hook_views_pre_render(&$view) { | |
switch ($view->name) { | |
case 'YOUR_VIEW_NAME': | |
// override the global custom text field value | |
$view->field['nothing']->options['alter']['text'] = 'My custom text'; | |
$view->field['nothing']->options['alter']['alter_text'] = TRUE; | |
break; | |
} | |
} |
This file contains hidden or 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
<ol> | |
<li> | |
<a class="use-ajax" | |
data-dialog-options="{"width":400}" | |
data-dialog-type="modal" | |
href="/node/1"> | |
First article displayed in modal dialog. | |
</a> | |
</li> | |
<li> |
This file contains hidden or 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
https://www.drupal.org/docs/8/modules/commerce-iats/how-to-setup-recurring-payments | |
Commerce Membership- | |
Install Module:- | |
1. Drupal commerce install via composer - composer require "drupal/commerce" | |
2. Install commerce_recurring module - composer require "drupal/commerce_recurring" | |
3. Install commerce_license module - composer require "drupal/commerce_license" |
This file contains hidden or 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
use Drupal\node\Entity\Node | |
Working with nodes Load a node by NID: | |
$nid = 123; // example value | |
Method 1 | |
$node_storage = \Drupal::entityTypeManager()->getStorage('node'); | |
$node = $node_storage->load($nid); | |
Method 2 |
This file contains hidden or 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
get current user in drupal 8 | |
Description: In drupal 7 we get the current user object by defining global $user but in drupal 8 this quite different. If you want to get current user object then follow below code. | |
$current_user = \Drupal::currentUser(); | |
$uid = $current_user->id(); | |
It returns user id of current user. | |
$user_mail = $current_user->getEmail(); | |
It returns user email id. |
This file contains hidden or 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
Example URL - http://xandeadx.ru/blog/drupal/946 | |
--- | |
$ composer require drush/drush | |
--- | |
$link = \Drupal\Core\Link::createFromRoute('My link', 'entity.node.canonical', ['node' => 123]); | |
// По пути |
This file contains hidden or 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
/** | |
* Implements hook_views_pre_render(). | |
*/ | |
function custom_views_pre_render(ViewExecutable $view) { | |
if (isset($view) && ($view->storage->id() == 'super_awesome_view')) { | |
$view->element['#attached']['library'][] = 'custom/custom_view'; | |
} | |
} |
NewerOlder