Blog

In your theme's template.php file, you could add something like **/ /** * Implements hook_preprocess_html */ function THEME_NAME_preprocess_html(...
Get user role of current loggedin user $user_roles = \Drupal::currentUser()->getRoles(); Get user detail of curent loggedin user $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); user_delete(uid); $user_roles = \Drupal::currentUser()->getRoles(); $user = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id()); $uid = $user->get('uid')->value;
global $user; $nid = 4; //nid is the node id of your webform. $node = node_load($nid); The values to save. Take case about array indexes! (see below) $data = array( '1' => array('0' => $type), '2' => array('0' => $method), '5' => array('0' => $volume), '6' => array('0' => $comment), '7' => array('0' => $phone), '8' => array('0' => $length) ); $...
When we enabled cache and check "Aggregate CSS files" and "Aggregate JavaScript files"  at ca/admin/config/development/performance but sometime we don't want to compress some specific CSS and JS files. Method 1. You can add css as given format, by using {preprocess: false} with file name we can exclude that css or js from aggregation mylibraryname: css: theme: css/...
When we create views by using flexslider by default its slide one image on click/slide. If you want slide multiple images in one slide follow these step. Step 1: Open '/admin/config/media/flexslider' and add  new setting Step 2: On tab "General Slideshow and Animation Settings" change setting according to following instructions Flexslider settings as follows: Starting Slide = 1...
I found issue with my website, when I have enabled SSL then compressed CSS and JS doesn't work. If disable compression of JS and CSS then worked but its issue with loading speed.  I found solution for this issue I have added this code in settings.php then its works fine. put your domain name instead of website $base_url = 'http://www.website.com';
If you have already created a webform then you can follow thi step 1. Open this url /admin/structure/webform (Structure -> Webform) 2. Click on "Build" in OPERATIONS column 3. Click on "+Add element" button, there will be seen a list form element 4. You can select Captcha from available list.
Set current date in custom form element in DRUPAL8 Add this line at top use Drupal\Core\Datetime\DrupalDateTime; function HOOK_form_alter(&$form, FormStateInterface $form_state, $form_id) { if ($form_id == 'node_article_form') { $form['field_date']['widget'] = array( '#type' => 'datetime', '#title' => 'Enter Date', '#required' =>...
Method to redirect on node id url $url = Url::fromRoute('entity.node.canonical', ['node' => $nid]); $form_state->setRedirectUrl($url); Method to redirect on custom url $url = Url::fromRoute('olsys.mycustom_dashboard'); $form_state->setRedirectUrl($url); Redirect on user view page of loggedin user use Drupal\Core\Controller\ControllerBase; // Use this on top return $this->...
Code to query for getting node according to field condition in DRUPAL 8 $query = \Drupal::entityQuery('node') ->condition('status', NODE_PUBLISHED) ->condition('type', 'custom_type'); $and = $query->andConditionGroup(); $and->condition('custom_taxonomy', 2); $query->condition($and); $and = $query->andConditionGroup(); $and->condition('custom_taxonomy', 8); $...

Pages