[TYPO3-mvc] FLUID :: how can you access properties of m:n related objects?

Roland most.wanted at gmx.at
Thu Nov 3 11:19:48 CET 2011


> I would write a dedicated viewhelper or getter in your DomainModel to
> retrieve the first object.
> For the getter approach you can write something like that:
>
> public function getFirstZulassung() {
> $object = $this->getZulassungen() // Or whatever
> // Maybe you can drop the instanceof validation
> if($object instanceof Tx_Extbase_Persistence_ObjectStorage) {
> $object->rewind();
> if($object->valid()) {
> return $object->current();
> }
> }
> }

i would have to put your function into Produkt.php (domain model class) 
and then assign the first Zulassung to the view in the 
ProduktController.php?

i tried to assign it by editing the listAction():

--- quote ---

	/**
	 * action list
	 *
	 * @return void
	 */
	public function listAction() {
		$produkts = $this->produktRepository->findAllOrdered(array('name' => 
Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING));
		$firstZulassung = $this->getFirstZulassung();
		$this->view->assign('produkts', $produkts);
		$this->view->assign('firstZulassung', $firstZulassung);
	}

--- /quote ---

but then i get this error message:

--- quote ---
Fatal error: Call to undefined method 
Tx_Gebroprodukte_Controller_ProduktController::getFirstZulassung() in 
/Users/rolandwaldner/Projekte/geb-gebro-pharma-website/typo3conf/ext/gebroprodukte/Classes/Controller/ProduktController.php 
on line 61
--- /quote ---

i can imagine that "$firstZulassung = $this->getFirstZulassung();" can 
not work in this context, but i do not know how this should look like 
that it works in the end.





More information about the TYPO3-project-typo3v4mvc mailing list