-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Hard to implement a ContentCulturePicker in Liquid #16202
Comments
Please elaborate and use the template, because at this point, this issue is not yet actionable. |
Currently we only have this template to override: Line 4 in 8ef3a02 The ContentCulturePickerContainer, which was available earlier, had a Model which allowed liquid templates like this:
ContentCulturePicker template does not provide a ViewModel (Model.SupportedCultures, Model.CurrentCulture) that would allow a template like the given one. I may be missing some liquid calls, which would allow that, but I cannot see them in the documentation. |
ContentCulturePicker.cshtml should be something like this:
followed by a call to the ContentCulturePickerContainer should then contain the rest of the current template - something like this:
This would reenable overriding with liquid. Why was that dropped in the first place? |
OK, so the point as far as I understand is that while you can override var supportedCultures = (await LocalizationService.GetSupportedCulturesAsync()).Select(c => CultureInfo.GetCultureInfo(c)); (Note that fetching the current culture is possible, see https://docs.orchardcore.net/en/latest/reference/modules/Liquid/#culture.) Without the changes in |
What I think we need is a way using Liquid to return culture info. I don’t have time to look now, @Piedone do you know if we have a Culture info liquid object? We either need a function or a filter that would return the following info:
|
Th PR #16208 adds a filter that would provide you the supported cultures. |
While that's great, why can't the driver produce these values, just as before? |
If I recall correctly, in the past |
If we do it with the dynamically added properties like they were then yes. So, basically revert this and the corresponding template change and I think we're good. Having a Liquid filter in addition to this is nice to have, but this would make it easier to simply override this shape (also from Razor BTW). Unless there's a good reason not to let the driver produce the two values. |
I am not sure what part to roll back so this issue is solved. If you have a suggestion, maybe a PR will help. |
The linked driver and corresponding template changes. The again, was there a particular reason for these? |
Yes the change is because we now have Navbar shape that is rendered in the top. The the driver what injects the template as a navbaritem. I don’t think you should change the driver or the template. Most people are not impacted by that change. The only impact of one is overriding that template using Liquid, and now they can with the new PR. Before we have a container view that was injected using a filter which creates a picker shape |
But why does that affect if this driver can pass parameters to the shape? |
I recall the details. It should not. But the fact that was changed indicates there was a reason for it. Feel free to try it out and see if anything breaks. I would setup a site using 1.8 and then run the 2.0 code on it. |
Not the same thing as So you cannot access the NativeName using liquid currently. |
@bashuss the PR was not yet merged into main so it will not work until after the PR is merged. I have added more properties like DisplayName and NativeName of the current culture. |
@MikeAlhayek Thanks for the info - I still do not really know my way around gitHub. If I would, I may even directly contribute a bit. Thanks for adding the properties! |
This works with that PR, BTW: <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="oc-culture-picker" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ Culture.NativeName }}
</a>
<div class="dropdown-menu" aria-labelledby="oc-culture-picker">
{% assign cultures = Culture | supported_cultures %}
{% for culture in cultures %}
{% if culture.Name == Culture.Name %}
{% continue %}
{% endif %}
<a class="dropdown-item">{{ culture.NativeName }}</a>
{% endfor %}
</div>
</li> I didn't spend time on the link, that's pretty standard. But I still argue we should revert the driver change: #16208 (comment) |
@sebastienros
no, it does not in 2.0.0-preview-18222:
before, it was possible to override the shape with liquid and get all the required data as part of the Model.
I guess the problem is, that
ContentCulturePickerContainer
is not invoked anymore, so you directly need to overrideContentCulturePicker
As the
ContentCulturePicker
does not work with a Model, but creates variables with the required data inside the template itself, there is no way to access this data inside a liquid template, which overrides the template.Am I missing a way to call this in liquid to get the equivalent for
Model.SupportedCultures
?var supportedCultures = (await LocalizationService.GetSupportedCulturesAsync()).Select(c => CultureInfo.GetCultureInfo(c));
Originally posted by @bashuss in #15148 (comment)
The text was updated successfully, but these errors were encountered: