Stash ro'yxati - juda ko'p natijalar ko'rsatilmoqda

Menda 10 ta natija ko'rsatilishi kerak, yoki kategoriya ma'lumotlariga asoslangan holda 10 ta natijaga qaramasdan yangiliklar sahifasi mavjud.

Mening kodim URLda kategoriya urlining mavjudligini tekshiradi va natijada ushbu toifadagi natijalarni cheklash uchun kategoriya identifikatori bilan so'rovni bajaradi, aks holda to'liq so'rovni bajarish uchun qaytariladi.

Men mantiqni sinab ko'rdim va shartli va EE so'rovlarim kutilgandek ishlaydi, lekin men Stash ro'yxatini chiqqanda ushbu kategoriyada bo'lmagan yozuvlarga natijalarni ko'rsatmoqda.

Ikki xil nom ro'yxatiga ega bo'lishim kerakmi?

{if segment_2_category_id != ''}

        {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
            {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10" category="{segment_2_category_id}"}
                {stash:item_title}{title}{/stash:item_title}
                {stash:item_url}{url_title}{/stash:item_url}
                {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                {stash:item_copy}{news_content}{/stash:item_copy}
                {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
                {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                    {news_videos_images}
                        {stash:item_image}{image}{/stash:item_image}
                        {stash:item_video}{video}{/stash:item_video}
                    {/news_videos_images}
                {/exp:stash:set_list:nested} 
            {/exp:channel:entries}
        {/exp:stash:set_list}
    {if:else}

        {exp:stash:set_list name="news_list" parse_tags="yes" parse_depth="2"}
            {exp:channel:entries channel="news" status="open|featured" orderby="date" sort="desc" limit="10"}
                {stash:item_title}{title}{/stash:item_title}
                {stash:item_url}{url_title}{/stash:item_url}
                {stash:item_date}{entry_date format="%F %d, %Y "}{/stash:item_date}
                {stash:item_copy}{news_content}{/stash:item_copy}
                {stash:item_entry_id}{entry_id}{/stash:item_entry_id}
                {exp:stash:set_list:nested name="item_media" context="{entry_id}" parse_tags="yes"}
                    {news_videos_images}
                        {stash:item_image}{image}{/stash:item_image}
                        {stash:item_video}{video}{/stash:item_video}
                    {/news_videos_images}
                {/exp:stash:set_list:nested} 
            {/exp:channel:entries}
        {/exp:stash:set_list}
    {/if}
1
ajratish buyrug'i bo'lishi mumkin. Ifelse ifodasi o'rniga ikkita bitta ifodani sinab ko'rdingizmi? {agar agar segment_2_category_id! = ''} --- {/ if} {agar segment_2_category_id == ''} --- {/ if}
qo'shib qo'ydi muallif t3rse, manba
Buni javob berishga harakat qiling - agar siz buni qabul qilsangiz, buni juda qadrlashingiz mumkin. Qo'shimcha ma'lumot olish uchun bir necha havola qo'shildi.
qo'shib qo'ydi muallif t3rse, manba
Erwinheiser-ning sharhini qo'shish: Agar shartli tahlilni erta amalga oshirish uchun IfElse plaginini ishlatishingiz mumkin: devot-ee .com/add-ons/ifelse yoki github.com/croxton/Ifelse . Siz {exp: ifelse parse = "ichkarida"} ... kabi ifodalar va joylashtirish ro'yxatlarini kabi tashqi shartni o'rashingiz mumkin ... {/ exp: ifelse}
qo'shib qo'ydi muallif Romans-8---31-39, manba
Rahmatli bolalar. Erwinheiser taklifingizni ishladi. Rimliklarga bu plaginning boshlari uchun minnatdorchilik, juda foydali bo'lishi mumkin.
qo'shib qo'ydi muallif Felipe Voloch, manba

1 javoblar

Ehtimol, ajralish buyrug'i, chunki keyinroq uni ajralib chiqadigan ilg'or shartli holga keltiradi. Agar ikkita ifodani ishlatsangiz va siz belgilab qo'ying.

{if segment_2_category_id != ''}---{/if} {if segment_2_category_id == ''}---{/if} 

Parse tartibini batafsil tekshirish uchun http://johndwells.com/blog/expressengine-parse-order-advanced-conditionals-as-tag-parameters va @low ushbu muammoga nisbatan juda chuqur PDF-ga ega: loweblog.com/downloads/ee-parse-order.pdf

0
qo'shib qo'ydi