CodeIgniter Forums

Full Version: How to nest partials in partials? How to setup data of complex nested views?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]momsenmeister[/eluser]
Hi,

I just made some experiments with both the Template Library of Phil Sturgeon and Colin Williams.

I think, they both work quite similar, but I still have a problem that I just can't solve with the existing documentation.

What is the proper way to nest partials/views in partials/views?

I plan to build a complex website and I don't want to have a single line of code doubled.
So, for example, I would like to have a nested structure like this:

Code:
<layout>
  &lt;headerview /&gt;
  <navigationview />
     <contentview>
        <boxtitlepartial />
        <partial2 />
        <boxpartial>
           <boxtitlepartial />
           <partial4>
              <boxtitlepartial />
              <partial5 />
              <partial5 />
              <partial5 />
           </partial4>
        </boxpartial3>
     </contentview>
  <footerview />
</layout>

Or - in a more abstract description:

Code:
<partial0>
  <partial1 />
  <partial2 />
     <partial4>
        <partial5 />
        <partial6 />
        <partial7>
           <partial5 />
           <partial9>
              <partial5 />
              <partial6 />
              <partial6 />
              <partial6 />
           </partial9>
        </partial7>
     </partial7>
  <partial3 />
</partial0>

As a conclusion - I want the possibility to nest every view/partial in any other view/partial, in any depth, and set it all up in a single method of the controller.
All data setup and business logic should resist in the controller.

Is that possible? How?
How do you structure your views/partials when you have complex nesting?