0

Ive looked at many Switchee questions here, but can't find out why my channel entry id's aren't being called in an embedded template. Switchee is working (with text for test), but Im obviously making a mistake with how Im calling the channel entries.

{exp:switchee variable="{segment_1}" parse="inward"}
{case value="page-one"}
{exp:channel entries channel="assorted_content" disable="member_data|trackbacks|pagination|categories" limit="1" entry_id="49"}
page one body content...
{/exp:channel:entries}
{/case} 
{case value="page-two"}
{exp:channel entries channel="assorted_content" disable="member_data|trackbacks|pagination|categories" limit="1" entry_id="42"}
page two body content...
{/exp:channel:entries}
{/case}
{/exp:switchee}

I dont see why the entries aren't being parsed. Ive tried with all the content in one page (without using an embedded template) and it works. What's wrong?

0

Could just be something very simple, try changing segment_1 to {segment_1}.

{exp:switchee variable="segment_1" parse="inward"} means your looking for the word segment_1 ,

while {exp:switchee variable="{segment_1}" parse="inward"} tells EE to look for the value in the URL segment 1

| improve this answer | |
  • Thanks for this. Sorry, thats what Ive got - I made a mistake in the code (updated now). Switchee itself works - it calls text to specific pages when i test it. But it wont parse the channel entry I call. Im stumped. – Boshy Apr 7 '14 at 15:38
0

It looks like you're not declaring your {exp:channel:entries} tag correctly. You have {exp:channel entries}. Try removing the white space and inserted a colon.

| improve this answer | |
  • sorry, thats another stupid error in the writing of the code here. I was calling it correctly (using colon) but didnt copy/paste here, wrote too quickly! – Boshy Apr 8 '14 at 8:11
0

Solved - at least I have a workaround even if it's not the correct solution. I have to wrap the code in the embedded template in {exp:channel entries}{/exp:channel entries} as well as the case calls to entry ids. I didnt realise you had to/could do this.

I have this in the 1st embedded template with the switchee cases:

{exp:switchee variable="{segment_1}" parse="inward"}
{case value="page-one"}
{exp:channel:entries entry_id="49"}
   {embed="includes/_page_content"}
    {/exp:channel:entries}
{/case}

{case value="page-two"}
{exp:channel:entries entry_id="42"}
   {embed="includes/_page_content"}
    {/exp:channel:entries}
{/case}
{/exp:switchee}

Then I have this in the 2nd embedded template (_page_content.html) that calls the page html:

{exp:channel:entries channel="assorted_content" disable="member_data|trackbacks|pagination|categories" limit="1"}
{title}
{page_body}
etc...
{/exp:channel:entries}

Of course if I needed to call different channels for the entry ids Id specify that in the Switchee template each time.

This is only my first attempt at Switchee - I need to do more complex nested stuff later (in meta open graph conditionals). It might be that the if:else addon would work better for that, I dont know yet.

Thanks for help in keeping me thinking about what was wrong.

| improve this answer | |
  • I'm sorry, but you're still doing it wrong. I can't see one single reason for you to call exp:channel:entries around the embeds... Or even for use the switchee! You're doing nothing with the switchee, because the embed is the same and doesn't get any different variable. And... Why to set the entry_id parameter if you're using the page module? There's a lot of unnecessary code here. – Robson Sobral Jun 7 '14 at 12:47

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.