ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

How can I have 2 or more field groups in 1 channel? Or Nest a channel with in another channel.

October 22, 2013 9:56am

Subscribe [2]
  • #1 / Oct 22, 2013 9:56am

    Greg R

    7 posts

    Not even sure if I’m asking the right thing. Here is what I want to do. I have template 1 using channel A. Template 2 using channel B. And I have channel C which is being used in a snippet that is nested in template 1 and 2, between the opening and closing channel tags of channels A and B on both pages. I am trying to have the content contained on Channel C show in both Templates 1 and 2. Not sure if I’m doing it right. Here is and idea of my code which is not working.

    Here is a general idea of the code for both templates, omitting all other code:
        Template 1
          {exp:channel:entries channel="A"}
                {exp:channel:entries channel="C"}
                {/exp:channel:entries}
            {/exp:channel:entries}

      Template 2
          {exp:channel:entries channel="B"}
                {exp:channel:entries channel="C"}
                {/exp:channel:entries}
            {/exp:channel:entries}

    Everything works fine until I try to nest {exp:channel:entries channel="C"}, then the rest of the data for A and B does not show. I have a field group assigned to Channel C which I want the user only to edit once but have the data show on both templates A and B. I’m open to presenting the data from Channel C differently than the above. That was the only way I could think of doing it.

    Any help will be greatly appreciated. Thanks! G

  • #2 / Oct 22, 2013 7:47pm

    DigitalDoctors

    76 posts

    If you want to nest channel entries, you need to include them as embeds.  Basically, create a separate template for the code you want and write it like this:

    {exp:channel:entries channel=“A”}
                {embed='templateforc'}
    {/exp:channel:entries}
    {exp:channel:entries channel=“B”}
                {embed='templateforc'}
    {/exp:channel:entries}

    and in templateforc

    {exp:channel:entries channel=“C”}
    {/exp:channel:entries}
  • #3 / Oct 23, 2013 7:22am

    Greg R

    7 posts

    Thanks, I’ll try that.

    I was able to get it to work by separating my channel entries using pipes. {exp:channel:entries channel=“A|C”} Then using conditional comments. So the template looks something like this;


    {exp:channel:entries channel=“A|C”}
        {if channel_short_name == 'A'}
            content, content, content .......
        {/if}
        {if channel_short_name == 'C'}
            content, content, content .......
        {/if}
        {if channel_short_name == 'A'}
            content, content, content .......
      {/if}
    {/exp:channel:entries}


    Thanks again, G

  • #4 / Oct 23, 2013 8:54am

    Greg R

    7 posts

    DigitalDoctors, I just tried your suggestion and it works just fine. I think your way is the better choice, much simpler and less code. Thanks again. G

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases