This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » support » symfony 1.3 and 1.4 » [SOLVED] Doctrine Sluggable. Where is getSlug()?
[SOLVED] Doctrine Sluggable. Where is getSlug()? [message #102632] Fri, 16 July 2010 20:10 Go to next message
benkimkimben  is currently offline benkimkimben
Messages: 6
Registered: July 2010
Junior Member
It looks like Propel provides getSlug() for Sluggable models.

Why doesn't Doctrine provide accessors to slug in the base model class?????

Am I just missing it?

So in my model class I created something like

	public function getSlug(){
		$q = Doctrine_Query::create()
			->select('slug')
		  	->from('test_table')
		  	->where('id = ?', $this->getId());
		$band = $q->fetchArray();
		return $band[0]['slug'];
	}


is this right approach to access slug?
Reason I need getSlug() is so that I can customize URL's with slugs.

Thanks!

[Updated on: Fri, 16 July 2010 23:30]

Re: Doctrine Sluggable. Where is getSlug()? [message #102636 is a reply to message #102632 ] Fri, 16 July 2010 22:25 Go to previous messageGo to next message
esukf  is currently offline esukf
Messages: 65
Registered: December 2006
Member
Did you use the sluggable behaviour in you schema?

Article:
  actAs:
    Sluggable:
      unique: true
      fields: [title]


By default a column named slug will be added to your model and you can access it using:

$article->getSlug();


More info here http://www.doctrine-project.org/documentation/manual/1_2/zh/ behaviors:core-behaviors:sluggable
Re: Doctrine Sluggable. Where is getSlug()? [message #102637 is a reply to message #102636 ] Fri, 16 July 2010 23:28 Go to previous message
benkimkimben  is currently offline benkimkimben
Messages: 6
Registered: July 2010
Junior Member
Yes you are right getSlug() is a default method

It works great now. There probably was a syntax error.

By reading your comment I could tell my code was wrong and I didn't have to search for whole world what's wrong with doctrine. Thanks a lot.
Previous Topic:admin_input_file_tag not working
Next Topic:project:send-emails dont work because strategy always none
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software