0

Need to change Drupal 8 node/add page titles - there have been some answers here (most for Drupal 7), but none of them have worked.

So there is always Create in front of the title in add page - need to drop the part Create - how ?

Need to drop also word Edit in from the already created node in edit mode - how ?

If someone can point me in right direction and give me _preprocess_node_add_list or some node preprocess sample.

Regards

Virgo

1

Try with hook_preprocess_page_title

function myModule_preprocess_page_title(&$variables) {
  //- Get the Current route name 
  $route_name = \Drupal::routeMatch()->getRouteName();
  switch ($route_name) {
    //- Add node Page
    case 'node.add' :
      $variables['title'] = t('New add page title');
      break;
    //- Edit node Page
    case 'entity.node.edit_form' :
      $variables['title'] = t('test');
      break;
  }
}
  • Thank u all, got my result - although its much easier than I expected (and learn some in between too) . I did it through D8 blocksystem without any programming. This was good for what I was aiming for. – Virgo Jaani Oct 25 '18 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.