- Issue created by @thomas.frobieter
Just tested this functionality and it works for me. Are you sure that you correctly transfer the change to the template? Maybe instead of
term.id()
you should useterm_id
, as you do in the example with the function the core "path"?Just tested this functionality and it works for me. Are you sure that you correctly transfer the variable to the template? Maybe instead of
term.id()
you should useterm_id
, as you do in the example with the function the core "path"?- Status changed to Closed: cannot reproduce
7 months ago 2:07pm 11 December 2023 - Status changed to Needs work
7 months ago 12:38pm 12 December 2023 Tested on a fresh D10 installation.
{{ drupal_url('taxonomy_term/1') }}
Prints out "/taxonomy_term/1", what is a 404.
The right path is "/taxonomy/term/1".Yep, thanks, this works correctly. So this is some kind of special case we should document? Other entities are typically ENTITY_TYPE/ENTITY_ID, and like always with Drupal Taxonomy, we have something.. special here.
https://git.drupalcode.org/project/twig_tweak/-/blob/3.x/docs/cheat-shee...
Current example:
{# Basic usage. #} {{ drupal_url('node/1') }}
At least make clear that this parameter is not about the entity type, but about the "route". Is this technically correct?
{# Basic usage: Provide any valid route (like: "node/1", "taxonomy/term/1") #} {{ drupal_url('node/1') }}
- ๐ท๐บRussia Chi
drupal_url()
accepts any URL, it doesn't really know if it an entity URL or something else like/admin/structure
. My knowledge of the backend functions is behind this are basically 0, but this is a URL: " https://www.drupal.org/node/1 โ ", if you pass this string to drupal_url(), it will fail ("InvalidArgumentException: The internal path component ' https://www.drupal.org/node/1 โ ' is external.").
So, from my understanding, it needs a "path" ( https://www.drupal.org/docs/user_guide/en/content-paths.html#s-what-is-a... โ ).
Is it okay for everyone to extend the documentation like this?
{# Provide any valid (internal) path (like: "node/1", "taxonomy/term/1") #} {# Basic usage #} {{ drupal_url('node/1') }} ...
- ๐ท๐บRussia Chi
if you pass this string to drupal_url(), it will fail
The function accepts what in Drupal is called user input not URL or path. The user input could be a system path or query string. Event anchor is acceptable. The primary usage of
Url::fromUserInput
is a UI where users can create some links, for example when configuring menus.The function is named
drupal_url
because it always returns a URL either relative or absolute.{# Provide any valid (internal) path (like: "node/1", "taxonomy/term/1") #}
Twig Tweak prepend
/
to the user input if it's missing. But I think the documentation should encourage users to provide paths in right way, with leading slashes (/node/1
,/taxonomy/term/1
, etc).Patch is welcome.
- Assigned to thomas.frobieter
Thanks for the explanation and your patience. I've used this function so often, always to get the URL Alias from ENTITY_TYPE/ENTITY_ID, never realized this is about the "path"/"user input" -_-
- Merge request !40Issue #3407926: Extend documentation for drupal_url() + add example for taxomy_term โ (Merged) created by thomas.frobieter
- last update
7 months ago 11 pass - Issue was unassigned.
- Status changed to Needs review
7 months ago 7:36am 13 December 2023 - ๐ฎ๐ณIndia Prashant.c Dharamshala
Prashant.c โ made their first commit to this issueโs fork.
- last update
6 months ago 11 pass - ๐ฎ๐ณIndia Prashant.c Dharamshala
Rephrased the documentation for "Drupal URL". Please review.
Thanks!
- Status changed to Needs work
6 months ago 8:29am 5 January 2024 - last update
6 months ago 11 pass - Status changed to Needs review
6 months ago 8:13am 8 January 2024 - last update
4 months ago 11 pass - Status changed to Fixed
4 months ago 6:26am 23 February 2024 -
Chi โ
committed c096aece on 3.x authored by
thomas.frobieter โ
Issue #3407926: Extend documentation for drupal_url() + add example for...
-
Chi โ
committed c096aece on 3.x authored by
thomas.frobieter โ
Automatically closed - issue fixed for 2 weeks with no activity.