Search This Blog

Friday, 11 May 2018

Drupal 8 basic Custom work



  • To get the current path or arg(1) etc.
     $request = \Drupal::request();
$current_path = $request->getPathInfo(); $path_args = explode('/', $current_path); $zero_argument = $path_args[0]; $first_argument = $path_args[1]; $second_argument = $path_args[2]; $third_argument = $path_args[3];

  • TO Get Node pathalias.
use Drupal\node\Entity\Node;
function bootstrap_preprocess_node(&$variables) { $node = $variables['elements']['#node'];
$node_detail = $node->toArray(); $node_detail['path'][0]['alias'];
}




No comments:

Post a Comment

First HTML blog

Hello there


echo 'dddd';
?>

Js to show Hide Content

Js: var showChar = 250;  // How many characters are shown by default     var ellipsestext = "...";     var moretext = "Sh...