[TYPO3-mvc] Get content elements from tt_content
Matt Janus
janus76uk at googlemail.com
Mon Mar 5 14:25:44 CET 2012
First of all I just wanted to say a big thank you to the group for the
support in helping me get my head round extbase and was hoping you
could help me out again.
I am creating an extension that will display content elements in tabs.
This plugin will use IRRE, so users can create tabs and then add
content elements to each tab.
I used the extension builder to create the domain model for the tab
with a simple title and a 1:n relation to the tt_content table.
The relevant sections of the model are below:
class Tx_myext_Domain_Model_Tab extends Tx_Extbase_DomainObject_AbstractEntity {
/**
* Title
*
* @var string
*/
protected $title;
/**
* Content Elements
*
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_Contenttools_Domain_Model_Elements>
*/
protected $contentElements;
/**
* Returns the title
*
* @return string $title
*/
public function getTitle() {
return $this->title;
}
/**
* __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;
}
}
This also adds the following field to the tt_content table
#
# Table structure for table 'tt_content'
#
CREATE TABLE tt_content (
tabs int(11) unsigned DEFAULT '0' NOT NULL
);
The backend works fine and allows me to create multiple tabs, each
with multiple content elements, my question is: how do I get the fully
rendered content elements in each tab object, that can then be passed
to a fluid template?
I believe this may have something to do with persistence mapping in
the TypoScript setup, but I am not sure how to go about this. Will
this just provide the raw information or will it provide the fully
rendered content element?
In a previous piBase extension this was done with $this->cObj->RECORDS
Any help and advice would be most appreciated.
All the best
Matt
More information about the TYPO3-project-typo3v4mvc
mailing list