Skip to content

Refactor: cleaner URL construction using global_url filter#1805

Merged
osma merged 4 commits intomainfrom
issue1565-refactor-twig-filter-vocab-url
Aug 28, 2025
Merged

Refactor: cleaner URL construction using global_url filter#1805
osma merged 4 commits intomainfrom
issue1565-refactor-twig-filter-vocab-url

Conversation

@osma
Copy link
Member

@osma osma commented Aug 27, 2025

Reasons for creating this PR

Generating URLs in Twig templates is ugly. This PR defines a new global_url Twig extension function/filter and uses it to construct URLs so that the logic is implemented in PHP code.

Link to relevant issue(s), if any

Description of the changes in this PR

  • define global_url filter
  • use the filter in base-template.twig instead of complicated Twig expressions

Known problems or uncertainties in this PR

None

Checklist

  • phpUnit tests pass locally with my changes
  • I have added tests that show that the new code works, or tests are not relevant for this PR (e.g. only HTML/CSS changes)
  • The PR doesn't reduce accessibility of the front-end code (e.g. tab focus, scaling to different resolutions, use of .sr-only class, color contrast)
  • The PR doesn't introduce unintended code changes (e.g. empty lines or useless reindentation)

@osma osma added this to the 3.0-beta.1 milestone Aug 27, 2025
@osma osma self-assigned this Aug 27, 2025
@osma osma moved this to Needs review in Skosmos 3.x Backlog Aug 27, 2025
Copy link
Contributor

@UnniKohonen UnniKohonen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the links seem to be generated correctly.

I guess the filter could be called global_url since it is used to create non vocabulary specific links. (And link_url could be called vocab_url but maybe that's confusing).

Also, is it possible to use the filter in landing.twig on line 23 to generate the vocab list links?

@osma osma changed the title Refactor: cleaner URL construction using vocab_url filter Refactor: cleaner URL construction using global_url filter Aug 28, 2025
@sonarqubecloud
Copy link

@osma osma merged commit 5160e22 into main Aug 28, 2025
14 checks passed
@github-project-automation github-project-automation bot moved this from Needs review to Issue/PR closed in Skosmos 3.x Backlog Aug 28, 2025
@osma osma deleted the issue1565-refactor-twig-filter-vocab-url branch August 28, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor: define vocab_url Twig filter for constructing links to vocabularies

2 participants