[TYPO3-mvc] Get content elements from tt_content
Matt Janus
janus76uk at googlemail.com
Mon Mar 5 16:34:57 CET 2012
I found a solution that works.
I removed the following from the model
/**
* Content Elements
*
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_Contenttools_Domain_Model_Elements>
*/
protected $contentElements;
/**
* __construct
*
* @return void
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
*
* @return void
*/
protected function initStorageObjects() {
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->contentElements = new Tx_Extbase_Persistence_ObjectStorage();
}
/**
* Returns the contentElements
*
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_Contenttools_Domain_Model_Elements>
$contentElements
*/
public function getContentElements() {
return $this->contentElements;
}
and added the following:
/**
* Content Elements
*
* @var integer
*/
protected $contentElements;
/**
* Returns the contentElements
*
* @return integer $contentElements
*/
public function getContentElements() {
return $this->contentElements;
}
I then used a view helper in the fluid template that get all content
elements from the tt_content table with tabs = uid of the tab object
public function render($tabID) {
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content',
'deleted = "0" AND hidden = "0" AND tabs='.$tabID, '',
'tt_content.sorting ASC', '');
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$cConf = array(
'tables' => 'tt_content',
'source' => ($row['uid']),
'dontCheckPid' => 1,
);
$content .= $GLOBALS['TSFE']->cObj->RECORDS($cConf);
}
$GLOBALS['TYPO3_DB']->sql_free_result($res);
return $content;
}
I'm sure there is 'neater' solution using the persistence mapping of
the model, but this will work for now.
All the best
Matt
More information about the TYPO3-project-typo3v4mvc
mailing list