Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #43 from district09/feature/HEAT-6742943
Browse files Browse the repository at this point in the history
HEAT-6742943: Fix "node_add_list" urls
  • Loading branch information
Jelle-S authored Aug 30, 2024
2 parents bd0828f + ddce4e0 commit b09e9f2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions og_sm_content/og_sm_content.module
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Link;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\og_sm\OgSm;
Expand Down Expand Up @@ -126,19 +127,19 @@ function og_sm_content_preprocess_node_add_list(&$variables) {
return;
}

/** @var \Drupal\Core\Utility\LinkGeneratorInterface $link_generator */
$link_generator = \Drupal::service('link_generator');
foreach ($variables['content'] as $type) {
/** @var \Drupal\node\NodeTypeInterface $type */
$url = new Url('og_sm.site_content.add', [
'node' => $site->id(),
'node_type' => $type->id(),
]);
$variables['types'][$type->id()]['add_link'] = $link_generator->generate($type->label(), $url);
$variables['types'][$type->id()]['add_link'] = Link::fromTextAndUrl($type->label(), $url);
// Also set the url key since themes like seven have a custom template for
// node_add_list.
$variables['types'][$type->id()]['url'] = $url;
}
// Claro/Gin use the bundle variable in their templates (cfr entity_add_list)
$variables['bundles'] = $variables['types'];
}

/**
Expand Down

0 comments on commit b09e9f2

Please sign in to comment.