Have a controller action, something like:
function filter($letter) {
$widgets = $this->Widget->find(
'all',
array(
'conditions' => array(
substr('Widget.name', 0, 1) => $letter
)
)
);
$this->set(compact('letter', 'widgets'));
}
Then $widgets is a variable in your view that contains only those whose name
starts with $letter. You can use the $letter variable to highlight the href for
that letter.
There are better ways of doing this (you could store the first letter of
'Widget.name' in a table field and search on that and you could use a model
function too. But this concept would work.
Jeremy Burns
Class Outfit
http://www.classoutfit.com
On 8 Nov 2011, at 16:12, Yves S. Garret wrote:
> What do you mean? <a href?
>
> On Tue, Nov 8, 2011 at 11:09 AM, Benni Graf <[email protected]> wrote:
> Hi there,
>
> Before someone tells you how to do what you want, let me ask you: Why
> don't you use a simple link instead of a form-button? That would make
> less markup and more sense to me. And with a certain amount of css you
> could easily make the link look like a button just to please your
> executives ;-)...
>
> Regards, Benni.
>
>
>
> On 8 Nov., 16:54, "Yves S. Garret" <[email protected]> wrote:
> > Before I even go on, here is what I have:
> >
> > View:http://bin.cakephp.org/view/404159005
> > Controller:http://bin.cakephp.org/view/21698870
> >
> > The idea that I'm trying to do is have a row of buttons spanning the
> > alphabet. The user clicks on the button and then it lists all of the
> > people with their last name starting with the specific letter. This is a
> > requirement, yes, I know, you can just type in 'R' and hit Enter and the
> > same thing will be done, no, this did not please powers-that-be. Moving
> > on...
> >
> > I didn't want to create a function for _every_ button. That seemed painful
> > and just bad coding. I would like to call that method and then pass in a
> > value (in this case, a string of one length) and the method will perform a
> > specific function based on the input. I tried this line of code:
> > echo $this->Form->button($letter, array('action' => 'view_admit_lookup'));
> >
> > I did some digging
> > online:http://book.cakephp.org/view/1415/buttonhttp://api.cakephp.org/file/cake/libs/view/helpers/form.php#method-Fo...
> >
> > I couldn't find anything that would do this for me easily. Am I missing
> > something? Did I look into the wrong docs?
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at
> http://groups.google.com/group/cake-php
>
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at
> http://groups.google.com/group/cake-php
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php