Reputation: 533
I'm actually writing an extension for an xml export of my pagetree and the content elements. With the following example I've mapped the typo3 "pages" table on my Page model:
# typo3conf/ext/my_publisher/Configuration/TypoScript/setup.txt
# Module configuration
module.tx_mypublisher.persistence.classes {
Tx_MyPublisher_Domain_Model_Page {
mapping {
tableName = pages
recordType = Tx_MyPublisher_Domain_Model_Page
columns {
uid.mapOnProperty = uid
pid.mapOnProperty = pid
sorting.mapOnProperty = sorting
deleted.mapOnProperty = deleted
title.mapOnProperty = title
is_siteroot.mapOnProperty = is_siteroot
}
}
}
}
Now I want to retrieve the pages in my controller...
$pages = $this->pageRepository->findAll();
This function provides me the result of my model table which is empty until now. So I think I need some "initialize" method in my repository that fills my model table, but until now I've no approach how I can solve this.
Has anyone a solution approach for this problem?
I work with Typo3 6.1.1.
Excuse my English i know it's not the best
Upvotes: 3
Views: 2338
Reputation: 55798
First: remove recordType = Tx_MyPublisher_Domain_Model_Page
from your mapping, it causes that your repo contains only records which was created as YOUR page, and I assume, that you want to gat any page(s) . Literally, it includes condition to your statement like (depending TCA settings) AND record_type = 'Tx_MyPublisher_Domain_Model_Page'
...
Second: make sure that the storagePid
is IGNORED
in all your queries, if you'll force some storagePid
by TypoScript you'll get only subpages of given page... The easiest way to do that is avoiding storagePid
in whole repo, add this method to your PageRepository
public function initializeObject() {
$this->defaultQuerySettings = $this->objectManager->create('Tx_Extbase_Persistence_Typo3QuerySettings');
$this->defaultQuerySettings->setRespectStoragePage(FALSE);
}
Third: Use this tip for checking queries for pages
table, it isn't comfortable, however it's the fastest way to find why your repo doesn't get required data (just copy the statement and paste it tou your favorite DB GUI).
(preferably, paste it to your question, so we will can see what's wrong)
If there are some questions marks like AND pages.pid = ?
in the debugged statement of course you need to replace them with required value AND pages.pid = 123
Upvotes: 1
Reputation: 872
I think you need to set a storagePid, since your findAll-query relies on that.
# TS
plugin.tx_yourext {
persistence {
storagePid = {$plugin.tx_yourext.persistence.storagePid}
}
}
# Or in query
$query->getQuerySettings()->setStoragePageIds(array($yourId);
In your case it could be 0 or whatever page you want to start your export with. But that will only give you pages that are children of the page with the storagePid as its uid. If you want to export a whole pagetree, you need a recursive function. Also you have to get a relation between your content elements and your page.
Upvotes: 0