Monday, August 27, 2012

Re: Passing arguments to a Pages

You could use SluggableBehavior in the Page model.

Router::connect(
'/clienti/:slug',
array(
'controller' => 'pages',
'action' => 'view'
),
array(
'slug' => '[-a-z]+'
'pass' => array('slug')
)
);

And change your controller:

public function view($slug = null)

You could call it "regione" if you like but I like to use the generic
"slug" to make it clear what it is. (I usually have several different
slugs across my routes.)

I included a leading hyphen in the regex so you can have regions like
"emilia-romagna". Also, it expects the slugs to be all lowercase as
this is what SluggableBehavior will do.

On Sun, Aug 26, 2012 at 5:47 AM, Mariano C. <mariano.calandra@gmail.com> wrote:
> I've a page (i.e. under Pages directory) called dettaglio_regione.ctp. I
> want to set URLs like http://.../clienti/[[regione]], so a working URL
> should be something like http://.../clienti/Campania or
> http://.../clienti/Sicilia and so on.
> I need to grab the content of [[regione]]. How I've to set the route?
>
> --
> 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+unsubscribe@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
>
>

--
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+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.

No comments: