[Solar-talk] back to layouts and views

Rodrigo Moraes rodrigo.moraes at gmail.com
Sun Aug 20 05:41:03 PDT 2006


Paul,
I think now I have a better understanding of how layouts & views work:
when you include a template using "include $this->template()" inside a
"layout", the Layout directories are searched for that template. When
you include a template inside a "view", the View directories are
searched for that template. Makes a lot of sense.

I was trying to include *views* dynamically inside a *layout*:

    <?php foreach($this->main_content as $id => $data) { ?>
        <h3><?php echo $this->getText($data['title']); ?></h3>
        <div class="main_box">
            <?php include $this->template($data['template']); ?>
        </div>
    <?php } ?>

Then I set views depending on the needs inside actions:

    $this->main_content[] = array(
        'title'     => 'AREAS_TITLE',
        'template'  => '_areas.php',
    );

My confusion was about when the layout or the views directories are
searched. The solution was to move the portions with "include
$this->template()" from the layout to a main view, and use that view
all the time.

rodrigo


More information about the solar-talk mailing list