public function save()
{
$this->slug = $this->_unique_slug(url::title(empty($this->slug) ? $this->title : $this->slug));
return parent::save();
}
private function _unique_slug($str)
{
static $i;
$original = $str;
while ($post = ORM::factory('post', $str) AND $post->loaded AND $post->id !== $this->id)
{
$str = $original.$i;
$i++;
}
return $str;
}
http://forum.kohanaframework.org/discussion/comment/17756/#Comment_17756
0 comments:
Post a Comment