CodeIgniter Forums
How to nest partials in partials? How to setup data of complex nested views? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to nest partials in partials? How to setup data of complex nested views? (/showthread.php?tid=35576)



How to nest partials in partials? How to setup data of complex nested views? - El Forum - 11-03-2010

[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?