You can still create a virtual full_slug field, just use concat() to
concatenate the parent slug, a slash, and the slug.
Or, since all of your data should already be set in the view anyway,
just create a helper that accepts Item data in the form of:
array(
'Item' => array(
'field1' => 'val1',
'field2' => 'val2',
...
'slug' => 'slug value'
),
'ParentItem' => array(
...
'slug' => 'parent slug value'
)
)
and outputs a correctly formatted link.
On Jun 10, 4:31 pm, RobertMeisner <[email protected]> wrote:
> Hello fellow cakers.
>
> How can I solve the following problem.
>
> Let's say you have a model called "Item".
> Item has a parent Item and a slug.
> I use a slug to Identify Item.
> URLs have the formhttp://domain/items/view/slug
>
> What I want to achieve is: URLs containing parents' slugs .
>
> ie:http://domain/items/view/parentparentslug/parentslug/slug
>
> I would preffer some Automagic solution, where i can use
> $html-> link ('controller' => 'item', 'action' => 'view', 'slug' =>
> 'my-item-slug'); //without parrents
>
> I thought about overriding AppHelper:: url (); and calling some
> getParentSlugs() function on Item model but as far as i know cake's
> Good Practices i shoudnt use Model calls in helpers.
>
> Another idea was to calculate some virtual full_slug field in
> afterFind() but i want path-of-slugs to be separated by slashes.
>
> What should be my approach on this one?
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
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