Browse Source

Better slug handling

imwald
Nuša Pukšič 3 months ago
parent
commit
1a80ac97ff
  1. 2
      src/Controller/ArticleController.php
  2. 4
      templates/components/Molecules/Card.html.twig

2
src/Controller/ArticleController.php

@ -60,7 +60,7 @@ class ArticleController extends AbstractController
/** /**
* @throws InvalidArgumentException|CommonMarkException * @throws InvalidArgumentException|CommonMarkException
*/ */
#[Route('/article/d/{slug}', name: 'article-slug')] #[Route('/article/d/{slug}', name: 'article-slug', requirements: ['slug' => '.+'])]
public function article( public function article(
$slug, $slug,
EntityManagerInterface $entityManager, EntityManagerInterface $entityManager,

4
templates/components/Molecules/Card.html.twig

@ -6,9 +6,9 @@
{% endif %} {% endif %}
<small>{{ article.createdAt|date('F j Y') }}</small> <small>{{ article.createdAt|date('F j Y') }}</small>
</div> </div>
{% set link = path('article-slug', {slug: article.slug}) %} {% set link = path('article-slug', {slug: article.slug|url_encode }) %}
{% if cat and mag %} {% if cat and mag %}
{% set link = path('magazine-category-article', {slug: article.slug, cat: cat, mag: mag}) %} {% set link = path('magazine-category-article', {slug: article.slug|url_encode, cat: cat, mag: mag}) %}
{% endif %} {% endif %}
<a href="{{ link }}"> <a href="{{ link }}">
<div class="card-header"> <div class="card-header">

Loading…
Cancel
Save