Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way of constructing URLs for the landing page (Skosmos 3) #1565

Open
osma opened this issue Nov 24, 2023 · 0 comments
Open

Better way of constructing URLs for the landing page (Skosmos 3) #1565

osma opened this issue Nov 24, 2023 · 0 comments

Comments

@osma
Copy link
Member

osma commented Nov 24, 2023

Description of the enhancement

Our Skosmos 3 Twig templates contain code like this for constructing the URL to the home page:

<a id="skosmos-logo-top" href="{{ request.lang }}/{% if request.contentLang and request.contentLang != request.lang %}?clang={{ request.contentLang }}{% endif %}{% if request.queryParam('anylang') == 'on' %}{% if request.contentLang == request.lang %}?{% else %}&{% endif %}anylang=on{% endif %}">

(the same kind of snippet appears at least two more times further down in the same file)

This is a very cumbersome and fragile way of constructing the URL, which usully amounts to something like /en or /fi or /fi?clang=en . For other kinds of URLs, we already have defined a custom filter link_url for Twig. I think the same or similar filter should be used here, which would move the URL construction logic away from the Twig template and into the PHP backend code, which is better suited for this kind of conditional URL string manipulation.

Who are the users that would benefit from the enhancement and how?

Developers trying to keep sane

What new functionalities would the enhancement make possible?

Make the Twig template cleaner and easier to understand

Why is the enhancement important?

Refactoring early is good.

@osma osma added this to the 3.0 milestone Nov 24, 2023
@osma osma added this to Proposed Skosmos 3.0 issues (to do) in Skosmos 3.0 Backlog via automation Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Skosmos 3.0 Backlog
  
Proposed Skosmos 3.0 issues (to do)
Development

No branches or pull requests

1 participant