[TYPO3-mvc] Howto check if object with a specific uid is related to an object (m:n relation)?

Roland most.wanted at gmx.at
Wed Nov 16 18:04:51 CET 2011


i found a solution - i do not know, if it is a clean one:

--- Download.php ---

/**
  * Checks, if Download is of type #1.
  *
  * @return boolean
  */
public function getStatusType1() {
	$types = $this->getTypes();
	foreach ($types as $type) {
		if ($type->uid == 1)
			return 1;
	}
	return 0;
}

--- /Download.php ---

then i use something like this in my fluid template:

--- quote ---

<f:if condition="{download.statusType1} == 1">...</f:if>

--- /quote ---

what do you think - is this a good solution? Can you do it better/cleaner?

kind regards.

roland


More information about the TYPO3-project-typo3v4mvc mailing list