0

I am trying to use a nested Switchee statement to display an embedded template but the results are a blank page. Using default status group and EE 2.11.5. I feel like I am missing something basic here.

The logic is: If SEGMENT 2 is NOT BLANK then display correct embedded template based on the Entry Status.

PASS (shows _sometemplate_home): xyz.com/somegroup
FAIL (shows blank): xyz.com/somegroup/open-status-entry
FAIL (shows blank): xyz.com/somegroup/closed-status-entry

<!-- COMPLETE somegroup/index.html template -->

{exp:switchee variable="{segment_2}" parse="inward"}

{case value="''"}
    {embed="somegroup/_sometemplate-home"}
{/case}

{case value="#^P(\d+)$#"}
    {embed="somegroup/_sometemplate-home"}
{/case}

{case default="Yes"}
    {switchee variable="{status}" parse="inward"}

        {case value="open"}
            {embed="somegroup/_sometemplate-open"}
        {/case}

        {case value="closed"}
            {embed="somegroup/_sometemplate-closed"}
        {/case}

    {/switchee}
{/case}   
{/exp:switchee}
  • 1
    I am starting to think the issue is because at this stage no channel entries have been parsed so there is no Status field to check for... – Cheyney May 22 '17 at 4:56
  • As answered below by Jelle, there was no channel entries yet so nothing to render. – Cheyney May 22 '17 at 13:10
1

As @checyney said there is no channel:entries loop yet. I'd suggest you do it something like this:

{case default="Yes"}
    {exp:channel:entries}
        {switchee variable="{status}" parse="inward"}

            {case value="open"}
                {embed="somegroup/_sometemplate-open" the_entry_id="{entry_id}"}
            {/case}

            {case value="closed"}
                {embed="somegroup/_sometemplate-closed" the_entry_id="{entry_id}"}
            {/case}

        {/switchee}
    {/exp:channel:entries}    

{/case}   
| improve this answer | |
  • Thanks for confirming. I can't believe I didn't see that until I had asked the question. – Cheyney May 22 '17 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.