You can call $this->element('name_of_element', $params), where $params
is an array of data that will be available in the element, the same
way $this->set('variable_name', $vars) works. That way, you can write
one element and simply change the data that is passed.
-J.
On Apr 20, 5:26 pm, Ben B <[EMAIL PROTECTED]> wrote:
> I am (very) new to CakePHP and I am working on a site where I will
> have "sub" navigation depending on which section a user is visiting.
>
> Right now I have it setup as follows:
>
> /answers/ renders /views/answers/index.thtml
> /answers/ask/ renders /views/answers/ask.thtml
> /answers/answer/ renders /views/answers/answer.thtml
>
> So answers will have a subnavigation that I currently have setup as an
> element in /views/elements/answers_nav.thtml which I then call in
> each /answers/ view.
>
> The code in the element is:
>
> <div id="section_nav">
> <ul>
> <li <? if ($this->action == "index") echo 'class="active"';
> ?>><a
> href=".">Overview</a></li>
> <li <? if ($this->action == "ask") echo 'class="active"';
> ?>><a
> href="ask">Asking a Question</a></li>
> <li <? if ($this->action == "Answer") echo 'class="active"';
> ?>><a
> href="answer">Answering a Question</a></li>
> </ul>
> </div>
>
> My question is: Is this the best practice or solution? Could I make
> this much simpler? I will have ~10-15 of these subnavigation elements
> in the /elements/ folder at this rate...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---