[TYPO3-mvc] Simple query by uid question
Felix Eggbert
eggbert at phez.com
Thu Oct 7 14:24:29 CEST 2010
Hi all,
I've just started working with extbase and fluid and I am kind of at the
very beginning.thanks to Sebastians and Jochens book ("Zukunftssichere
Extensions...") I am slowly getting into things...I have very good
experience with installing and setting up TYPO3 and some experience in PHP
and MySQL programming but I am beginner in typo3 extension
programming...therefore I hope this is the right place to ask this kind of
noob question...
This is my problem:
I have a model named "Category". This category has a 0..1 relation
("parent") to itself which is supposed to allow setting a parent category
which is from the same model.
The main categories have a (hidden) parent category ("main", uid=2) whose
only purpose is holding all main categories at the top level. Now I want to
output all top-level categories, meaning all categories with parent uid=2.
My controller action looks like this:
/**
* List all available main categories
*
* @return string The rendered view
*/
public function listAllMainAction(){
$mainCategories =
$this->categoryRepository->findMainCategories();
$this->view->assign('categories', $mainCategories);
}
And my repository method looks like this
/**
* Finds all main categories
*
* @return array Matched categories
*/
public function findMainCategories() {
$motherCategory = 2;
$query = $this->createQuery();
$query->matching($query->contains('parent',$this->findByUid((int)$motherCate
gory)));
return $query->execute;
}
But I don't get any results! A var_dump in listAllMainAction for
$mainCategories returns null. Of course I have set up all required
categories and a "normal" $this->categoryRepository->findAll() does return a
list of all categories.
What am I doing wrong?
Thanks for your help!
Regards,
Felix Eggbert
More information about the TYPO3-project-typo3v4mvc
mailing list