The element refers to data just like any other view. I use an element
to display task listings, and by choosing which data to pass to the
element, I get different displays on the same page:

<div class="related">
    <?php if (isset($userSlots)):?>
    <h3><?php __('You are signed up for');?></h3>
    <?php echo $this->element('signup_list', array( 'slots' =>
$userSlots )); ?>
    <?php endif; ?>
    <h3><?php __('Available Time Slots for '. $job['Job']
['job_name']);?></h3>
    <?php if (isset($availableSlots)):?>
    <?php echo $this->element('signup_list', array( 'slots' =>
$availableSlots )); ?>
    <?php else: ?>
    <h3>Nobody signed up for this job yet</h3>
    <?php endif; ?>

    <div class="actions">
        <ul>
            <li><?php echo $html->link(__('Show Jobs', true), array
('controller'=> 'jobs', 'action'=>'index'));?> </li>
        </ul>
    </div>
</div>


As you can see, I use the signup_list element with a different value
passed in as 'slots' each time ...

On Jan 2, 2:19 pm, bmaorlo <opao...@gmail.com> wrote:
> Thanks , and this re-usable view can have a controller ?
> If i want this view to take data from DB for example "login box" .
> How do i do the logic part on this view ?
>
> Thanks.
>
> On Jan 3, 12:04 am, WebbedIT <p...@webbedit.co.uk> wrote:
>
> > An element is simply a re-usable view ... rather than repeat a whole
> > view or a part of a view which is used multiple times across your app,
> > create a single element and use that across multiple views.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to