1

I'm not talking about embedding another template.

I'd like to embed all the child pages of a parent within the parent (for incredibly convoluted reasons).

I'm using Structure if that helps.

Using {exp:channel:entries entry_id="{structure:child_ids}" fixed_order="{structure:child_ids}"} I can get all of the child IDs that I need... I was hoping that something like {embed="{page_uri}"} would do the trick, but alas.

Any ideas?

2 Answers 2

0

I'm not sure how this will work out, recursively. Probably a huge performance hit and memory exhaustion leading to the parent page non-rendering at all. But, here is an outline of how you could do this (in pseudo EE code):

{!-- Parent template --}

Let's get our child ids.
{exp:channel:entries entry_id='{structure:child_ids}' fixed_order="{structure:child_ids}"}

    {embed='template_group/child_page_template' id='{child_id}'}

{/exp:channel:entries}

{!-- Child template normally used to show regular child page --}

Let's show our page, but load our channel loop depending on context.

{if embed:child_id}
    If passing an embed id...
    {exp:channel:entries id='{embed:child_id}' ... }
{if:else}
    If not, see if it's a normal structure page...
    {exp:channel:entries id='{structure:page_id}' ... }
{/if}

    Render it up!

{/exp:channel:entries}

I guess another solution would be to write an add-on that just CURLS the page via AJAX and then returns it to your template. Or, what would be even easier (if this is an option for you), just use the nav tag to dump URLs into iframes: http://buildwithstructure.com/documentation/navigation_examples/

If you could explain the context of this desired output and a slightly more specific example (like, COMPLETE child page renders, header+footer and all?), we can probably help more.

0

I'm not sure if it's the most efficient way... but after a lot of trial and error; this seems to be working.

{exp:channel:entries entry_id="{structure:child_ids}" fixed_order="{structure:child_ids}"}
  {exp:query sql="SELECT channel_id FROM exp_channel_titles WHERE entry_id = '{entry_id}'"}
    {exp:query sql="SELECT template_id FROM exp_structure_channels WHERE channel_id = '{channel_id}'"}    
      {exp:query sql="SELECT template_name FROM exp_templates WHERE template_id = '{template_id}'"}
        {embed="templates/{template_name}" id="{entry_id}"}
      {/exp:query}
    {/exp:query}
  {/exp:query}
{/exp:channel:entries}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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