Just do a find on your NavMenu in the model you are driving your view
from, and then you can access the data from your element.

I do this on my site in my "jobs" view, where I want to display a
couple differently filtered lists of "job slots". I populate the lists
into $userSlots and $availableSlots in my jobs_controller, then in my
view, I use the same element to display them by passing in those two
data sets:

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



On Dec 7, 8:08 am, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
> On Dec 7, 10:59 am, Rob <[EMAIL PROTECTED]> wrote:
>
> > Elements are definitely the way to go. I make extensive use of
> > elements for common display items.
>
> Okay, good. At least I'm not _way_ off base, then. Now, the follow-on
> question is this: how do I make an element data-driven? In my case,
> I'd want my element to have access to the NavMenu model in order to
> retrieve the items in any given menu. I haven't found much (read:
> anything) documented on this.
>
> > On the other hand, if you are just driving a common navigation, I'm
> > not sure you need an element since it can just go directly into the
> > layout.
>
> Except that it's data-driven and exists with slight variations in 3
> different locations within the layout.
>
> Thanks again.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to