21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 787 Views |
-
Getting table data for virtual page

30 July 2010 at 6:11am
Hi guys,
although i read the tutorials i guess i missed something.
I'm trying to show data from a database table on a page.
I've defined a Holder "ListingHolder" and a Page "ListingPage".
The ListingPage defines a table via static $db, nothing complex, just some fields.
The ListingPage controller has a method named ShowAllEntries.
In there i call DataObject::get('ListingPage') and expect to get all entries from the table ListingPage_Live.
Sadly, I only get the first row.
I've digged a bit deeper and found the reason for this:
The SQL Query generated fetches only Pages that have an entry in SiteTree_Live.
To summarize what I want to achieve:
When the Page "ListingPage" is called in the Browser, Silverstripe should generate a List of all entries in a table (atm ListingPage_Live), regardless if they belong to a page.
Why? I want to fill the table from an external data source, so I don't need a page per entry plus the amount of data is huge, so it would probably slow down the admin interface a lot.
Could you please give me a hint how to dump out the table data?
Thanks in advance, goosejan
-
Re: Getting table data for virtual page

30 July 2010 at 3:36pm
Why? I want to fill the table from an external data source, so I don't need a page per entry plus the amount of data is huge, so it would probably slow down the admin interface a lot.
If you are dealing with data pulled from a thirdparty and they don't need to be pages then you may want to use dataobjects instead of pages. Then you won't run into Live, Staging issues. If you want to proceed with keeping them page objects (which by the sounds of it you don't need to) then instead of DataObject::get() you can use Versioned::get_by_stage() to specifically get from the draft stage.
http://api.silverstripe.org/2.4/sapphire/model/Versioned.html#methodget_by_stage
| 787 Views | ||
|
Page:
1
|
Go to Top |


