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

Frontend menu disappear when enable localization for the frontend menu #16869

Closed
gaojianzhuang opened this issue Oct 11, 2024 · 2 comments
Closed
Labels

Comments

@gaojianzhuang
Copy link

gaojianzhuang commented Oct 11, 2024

Describe the bug

After I added the localization part for the menu content type(Content Types -> Menu -> Edit), the frontend menu disappeared.
image

image

Orchard Core version

version: 2.0.0
image

To Reproduce

Steps to reproduce the behavior:

  1. Go to 'Content Types -> Menu -> Edit.'
  2. Add "Localizaiton" part.
  3. Update the Menu content.
  4. The frontend UI menu disappears.

Expected behavior

The menu should display well, if I change the language, the menu should render with the language.

Logs and screenshots

image

The layout template codes:

{% shape "menu", alias: "alias:main-menu", cache_id: "main-menu", cache_fixed_duration: "00:05:00", cache_tag: "alias:main-menu" %}
{% assign cultures = Culture | supported_cultures %}
<div class="culture-picker dropdown">
    <button class="btn btn-success btn-sm dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">{{Culture.Name}}</button>
    <ul class="dropdown-menu dropdown-menu-end shadow">
        {% for culture in cultures %}
            {% if culture.Name != Culture.Name  %}
            <li><a class="dropdown-item" href="{{ culture.Name | switch_culture_url }}">{{ culture.Name }}</a></li>
            {% else %}
            <li><a class="dropdown-item active" href="{{ culture.Name | switch_culture_url }}">{{ culture.Name | t }}</a></li>
            {% endif %}
        {% endfor %}
    </ul>
</div>
@gaojianzhuang
Copy link
Author

gaojianzhuang commented Oct 11, 2024

I think I found the root cause.

{% shape "menu", alias: "alias:main-menu", cache_id: "main-menu", cache_fixed_duration: "00:05:00", cache_tag: "alias:main-menu" %}

The menu alias changed, I need to update the logic. The alias should be dynamic with the culture.

{% assign menuKey = "alias:main-menu-" | append: Culture.Name %}
{% assign menuCacheKey = "main-menu-" | append: Culture.Name %}
{% shape "menu", alias: menuKey, cache_id: menuCacheKey, cache_fixed_duration: "00:05:00", cache_tag: menuKey %}

@Piedone
Copy link
Member

Piedone commented Oct 11, 2024

Thanks for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants