OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.45k stars 2.41k forks source link

Mabye something wrong about LocalizationSetContentPickerField output sequence in liquid? #5913

Open jaliao opened 4 years ago

jaliao commented 4 years ago

An issue about LocalizationSetContentPickerField. I create a content type named CarouselBanner. This Content Type have a LocalizationSetContentPickerField named Banner.

so I create a Liquid file CarouselBanner-LocalizationSetContentPickerField.liquid

{% assign contentItems = Model.LocalizationSets | localization_set %}
<!-- LocalizationSets : {{ Model.LocalizationSets }} -->
<!-- contentItems : {{ contentItems }} -->
{% for contentItem in contentItems %}
    {{ contentItem | shape_build_display: "Detail" | shape_render }}
{% endfor %}

I add two content and output as bellow

{ "CarouselBanner": { "PlaySpeed": { "Value": 4000.0 }, "Autoplay": { "Value": true }, "Banner": { "LocalizationSets": [ "4dfgv5j95mn09v83akvndxcj4t", "43ct99z1wtnnq0k759msmz1y50", "44bqdyjstgpn740585yjbcefnk", "4y4fnf5t3e5z0rzamy278xpqn4" ] } }, "TitlePart": { "Title": "2" }, "LocalizationPart": { "LocalizationSet": "49d6r0qqkssdcymnqgj8mfzax8", "Culture": "en-US" } }

{ "CarouselBanner": { "PlaySpeed": { "Value": 4000.0 }, "Autoplay": { "Value": true }, "Banner": { "LocalizationSets": [ "4y4fnf5t3e5z0rzamy278xpqn4", "44bqdyjstgpn740585yjbcefnk", "43ct99z1wtnnq0k759msmz1y50", "4dfgv5j95mn09v83akvndxcj4t" ] } }, "TitlePart": { "Title": "1" }, "LocalizationPart": { "LocalizationSet": "4ya25qycenep72bbe67h8dmbdj", "Culture": "en-US" } }

These two record's LocalizationSets value are difference. means Model.LocalizationSets are difference in these two records But i try to output contentItems are the same data in there two records.

<!-- LocalizationSets : 4dfgv5j95mn09v83akvndxcj4t43ct99z1wtnnq0k759msmz1y5044bqdyjstgpn740585yjbcefnk4y4fnf5t3e5z0rzamy278xpqn4 -->
<!-- contentItems : Key visual 3Key visual 2Key visual 4Key visual 1 -->

<!-- LocalizationSets : 4y4fnf5t3e5z0rzamy278xpqn444bqdyjstgpn740585yjbcefnk43ct99z1wtnnq0k759msmz1y504dfgv5j95mn09v83akvndxcj4t -->
<!-- contentItems : Key visual 3Key visual 2Key visual 4Key visual 1 -->

does the Liquid filter localization_set re-Order the data? or how to write this code.

Best regards, Justin

hishamco commented 4 years ago

/cc @jptissot

jaliao commented 4 years ago

how about this? or tell me where is the source code?

thanks

jptissot commented 4 years ago

it should not reorder the data if I remember correctly. Code is here : https://github.com/OrchardCMS/OrchardCore/blob/6cddd9f9904ff117ba82587f39fc76f49fac3cc3/src/OrchardCore.Modules/OrchardCore.ContentLocalization/Liquid/ContentLocalizationFilter.cs#L35

https://github.com/OrchardCMS/OrchardCore/blob/6cddd9f9904ff117ba82587f39fc76f49fac3cc3/src/OrchardCore.Modules/OrchardCore.ContentLocalization/DefaultContentLocalizationManager.cs#L66

jptissot commented 4 years ago

Maybe look at this template as well:

https://github.com/OrchardCMS/OrchardCore/blob/6cddd9f9904ff117ba82587f39fc76f49fac3cc3/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/LocalizationSetContentPickerField.cshtml

jaliao commented 4 years ago

OK. Let me check.

jaliao commented 4 years ago

Maybe look at this template as well:

https://github.com/OrchardCMS/OrchardCore/blob/6cddd9f9904ff117ba82587f39fc76f49fac3cc3/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/LocalizationSetContentPickerField.cshtml

@jptissot it's the same with Liquid

one more question

what's this? Castle.Proxies.DisplayLocalizationSetContentPickerFieldViewModelProxy

this is my code

<!-- slider begin CarouselBanner-Banner {{ Model.Content.CarouselBanner-Banner }} -->
<section>
    {% assign PlaySpeed = Model.ContentItem.Content.CarouselBanner.PlaySpeed.Value %}
    {% assign Autoplay = Model.ContentItem.Content.CarouselBanner.Autoplay.Value %}
    <div id="bv-carousel" class="bv-carousel slick" data-autoplay-speed="{{ PlaySpeed }}" data-autoplay="{{ Autoplay }}">
        {{ Model.Content.CarouselBanner-Banner | shape_render }}
    </div>
</section>
<!-- slider end -->

and output is

<!-- LocalizationSets : 4dr4ccmff1p99xc1ehp811xrd4 -->
<!-- contentItems : Home Page Key Visual 20200414 -->
    <!-- slider begin CarouselBanner-Banner Castle.Proxies.DisplayLocalizationSetContentPickerFieldViewModelProxy -->
<section>
    <div id="bv-carousel" class="bv-carousel slick" data-autoplay-speed="4000" data-autoplay="true">
        <!-- CSHTML -->
<!-- LocalizationSets : {{ Model.LocalizationSets }} -->
<!-- contentItems : {{ contentItems }} -->
<!-- 
DisplayMode : Image 
BannerData : /media/0_HOME/0_Carousel/kv3.png
BannerURL : 
BannerTitle : Key visual 3
BannerContent :  
-->
    <div class="slide">
        <div class="slide-img" title="" style="background-image: url(/media/0_HOME/0_Carousel/kv3.png)"></div>
        <a href="" class="bv-carousel-caption">
            <h1 class="title">Key visual 3</h1>
            <div class="summary"></div>
        </a>
    </div>
<!-- 
DisplayMode : Image 
BannerData : /media/0_HOME/0_Carousel/kv2.jpg
BannerURL : 
BannerTitle : Key visual 2
BannerContent :  
-->
    <div class="slide">
        <div class="slide-img" title="" style="background-image: url(/media/0_HOME/0_Carousel/kv2.jpg)"></div>
        <a href="" class="bv-carousel-caption">
            <h1 class="title">Key visual 2</h1>
            <div class="summary"></div>
        </a>
    </div>
<!-- 
DisplayMode : Vedio 
BannerData : /media/0_HOME/0_Carousel/brand-film.mp4
BannerURL : /en-us/life_style
BannerTitle : Key visual 4
BannerContent :  
-->
    <div class="slide video">
        <div class="slide-video">
            <video autoplay loop playsinline muted="muted">
                <source src="/media/0_HOME/0_Carousel/brand-film.mp4" type="video/mp4">
            </video>
        </div>
        <a href="/en-us/life_style" class="bv-carousel-caption">
            <h1 class="title">Key visual 4</h1>
            <div class="summary"></div>
        </a>
    </div>
<!-- 
DisplayMode : Image 
BannerData : /media/0_HOME/0_Carousel/kv1.jpg
BannerURL : /en-us/life_style
BannerTitle : Key visual 1
BannerContent :  
-->
    <div class="slide">
        <div class="slide-img" title="" style="background-image: url(/media/0_HOME/0_Carousel/kv1.jpg)"></div>
        <a href="/en-us/life_style" class="bv-carousel-caption">
            <h1 class="title">Key visual 1</h1>
            <div class="summary"></div>
        </a>
    </div>

    </div>
</section>
<!-- slider end -->
jaliao commented 4 years ago

Maybe look at this template as well:

https://github.com/OrchardCMS/OrchardCore/blob/6cddd9f9904ff117ba82587f39fc76f49fac3cc3/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/LocalizationSetContentPickerField.cshtml

and i use this template the output is the same

<!-- slider begin CarouselBanner-Banner Castle.Proxies.DisplayLocalizationSetContentPickerFieldViewModelProxy -->
--
  | <section>
  | <div id="bv-carousel" class="bv-carousel slick" data-autoplay-speed="4000" data-autoplay="true">
  |  
  |  
  |  
  | <div class="field field-type-localizationsetpickerfield field-name-carousel-banner-banner">
  | <span class="name">Banner:</span>
  | <span class="value"><a display-for="Key visual 3">Key visual 3</a></span>
  | <span>,</span>
  | <span class="value"><a display-for="Key visual 2">Key visual 2</a></span>
  | <span>,</span>
  | <span class="value"><a display-for="Key visual 4">Key visual 4</a></span>
  | <span>,</span>
  | <span class="value"><a display-for="Key visual 1">Key visual 1</a></span>
  | </div>
  | </div>
  | </section>
  | <!-- slider end -->
jaliao commented 4 years ago

It always the same order, no matter how i re-order them.

jaliao commented 4 years ago

Finally, Back to use this ContentPickerField.

jptissot commented 4 years ago

Which version of OC are you using ?

jaliao commented 4 years ago
  <ItemGroup>
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
    <PackageReference Include="OrchardCore.Application.Cms.Targets" Version="1.0.0-rc1-12815" />
    <PackageReference Include="OrchardCore.Logging.NLog" Version="1.0.0-rc1-12815" />
  </ItemGroup>
sebastienros commented 4 years ago

can you try to use the latest version on MyGet?

jaliao commented 4 years ago

sorry. seem can't work. I will create a new demo project and share with you when I finished my project.

jaliao commented 4 years ago

https://github.com/jaliao/OCDEMO

jaliao commented 4 years ago

I can give you admin password, if you need.

jptissot commented 4 years ago

Sure, let me know, i'd like to see

jaliao commented 4 years ago

give me your email this is mine "justin.liao@outlook.com"