Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Template Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Custom Code / Environment & Data

Go to End

3 Posts   1376 Views


Community Member, 4 Posts

2 July 2009 at 7:12am

Couple questions here...

So I have a site that is more Data driven than page driven. To be sure, there are pages, but those pages contain iterable lists of data, as well as use additional 3rd party REST API's to get their data. I have used these 3rd Party API's before, and I have my own custom obejcts to handle them.

Question One:
Where is the best place for me to import my custom objects? mysite/code/MyPageController.php? I am assuming I should NOT store the code in mysite/code so I will be doing a require to get it in.

Question Two:
I have about 2000 records that I need pages for. Traditionally, I would make 1 template(not a silverstripe template) file, and change the content based on the query string. I assume this is possible in Silverstripe, and I am just looking in the wrong place. Or if it's not, is there a way for me to programatically import 2000 pages. Each page will contain at least 1 image, it's not a store so the commerce module is out or is it?

Question Three:
When dealing with 3rd Party APIs, is there an object that implements Iterator in Sapphire that can feed <% controls %> with a custom data source (lets just say an array) or does everything need to be derived from MySQL Queries for <% controls %>?

Thanks! Hope these questions make sense re: what I am trying to accomplish!


Community Member, 4 Posts

2 July 2009 at 8:07am

Edited: 02/07/2009 8:10am

Ok.. DataObject:

I can use that for the 2000 Items... that's all they are really are: DataObject's. How would I tell a page which DataObject it should use for it's data source?

There is this FileDataObjectManager() but it looks like I would still have to created 2000 pages, one for each DataObject.

Also how would you go about having different pages consume that data? Eg, say I need to have a list on Page1, and Page2, but Page3 is the origin of the DataObjects?


Community Member, 4 Posts

2 July 2009 at 8:17am

Looks like that shows me querying...

So I could use DataObject::get to share the data between pages.