I have the Sluggable Utility up and running and creating the slugs no issue.
Where I am stuck is I am trying to get the 'scope' => array() but working but just getting errors.
Maybe I misunderstood this key. I want slugs to be unique to the specific. So every user can have "my-first-post" slug which is unique to user_id
The slug is used in conjunction with the user:slug which is unique so in this case the post:slug only has to be unique to the user and not the entire site:
Example:
site/bob/post/my-first-post
site/george/post/my-first-post
site/carol/post/my-first-post
/**
* Default settings
*
* label - The field used to generate the slug from
* slug - The field to store the slug in
* scope - conditions for the find query to check if the slug already exists
* separator - the character used to separate the words in the slug
* length - the maximum length of the slug
* unique - check if the slug is unique
* update - update the slug or not
* trigger - defines a property in the model that has to be true to generate the slug
*
* Note that trigger will temporary bypass update and act like update is set to true.
*
* @var array
*/
So in ny model:
public $actsAs = array(
'Sluggable.Sluggable' => array(
'label' => 'title',
'slug' => 'slug',
'separator' => '-',
'scope' => array('user_id' => '???')
));
I tried passing the raw $this->data to get user_id but errors.
Tried AuthComponent::user('id'), errors.
Any ideas how I can accomplish this?
Thanks,
Dave
No comments:
Post a Comment