How do I add links to site settings into the settings description of my component?

Actually, I thought I knew because I translated something like <a href="/admin/site_settings/category/all_results?filter=top_menu">top menu site setting</a> several times, and it worked :tada:.
But the tests fail because links without %{base_path} or %{base_url} aren’t allowed.

So I searched for an example and found

I copied that:

<a href="%{base_url}/admin/site_settings/category/all_results?filter=top_menu">top menu site setting</a>

But then the link didn’t work. It became https://example.discourse.group/%%7Bbase_url%7D/admin/site_settings/category/all_results?filter=top_menu

When I installed Homepage Feature, the link there didn’t work either.

So I tried adding a trailing slash and using %{base_url}, but none of them worked.

<a href="/%{base_url}/admin/site_settings/category/all_results?filter=top_menu">top menu site setting</a> links to https://example.discourse.group/admin/customize/themes/%%7Bbase_url%7D/admin/site_settings/category/all_results?filter=top_menu

<a href="%{base_path}/admin/site_settings/category/all_results?filter=top_menu">top menu site setting</a> links to https://example.discourse.group/admin/customize/themes/%%7Bbase_path%7Dadmin/site_settings/category/all_results?filter=top_menu

<a href="/%{base_path}/admin/site_settings/category/all_results?filter=top_menu">top menu site setting</a> links to https://example.discourse.group/%%7Bbase_path%7D/admin/site_settings/category/all_results?filter=top_menu

But I wasn’t able to find a working solution

4 Likes

Once this PR is merged, you’ll be able to use %{base_path} in theme setting descriptions:

5 Likes

The core change is merged, and I’ve made a PR to fix the ā€œhomepage featureā€ theme component:

2 Likes

Since the relative links in the description of the settings of my component are currently working, I assume I should pin the version in compatibility to ensure they continue to work for those who don’t update Discourse at the same time.
I guess you didn’t pin because the links didn’t work before anyway — is that correct?

Yup that’s correct :+1:

1 Like