Jump to:

3447 Posts in 1031 Topics by 872 members

Template Questions

SilverStripe Forums » Template Questions » Custom Code / Environment & Data

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

Page: 1
Go to End
Author Topic: 1048 Views
  • logix812
    Avatar
    Community Member
    4 Posts

    Custom Code / Environment & Data Link to this post

    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!

  • logix812
    Avatar
    Community Member
    4 Posts

    Re: Custom Code / Environment & Data Link to this post

    Ok.. DataObject:
    http://www.silverstripe.org/dataobjectmanager-module-forum/show/260984#post260984

    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?

  • logix812
    Avatar
    Community Member
    4 Posts

    Re: Custom Code / Environment & Data Link to this post

    http://doc.silverstripe.com/doku.php?id=datamodel

    Looks like that shows me querying...

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

    1048 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.