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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Query Data from a custom Table


30 Posts   4231 Views

Carbon Crayon

13 March 2009 at 1:16am Community Member, 598 Posts

what is 'LocationSubmission' ? I don't think it is a page? If it's not a page then it can't have a link. Try replacing the <% control ShowLocation %> with the the function I suggested so <% control GetLocations %>. This will return the child pages which are of 'Location' type so if you wanted each location to be listed then you need to make a page for each.

I think you are getting confused with what is and what isn't a page. If you want LocationSubmission to have a link it needs to have it's own LocationSubmission.php with a model and a controller extending Page and Page_Controller respectively. It also needs a template file

Have a look through the tutorials to see how all this stuff works.


13 March 2009 at 1:39am Community Member, 44 Posts

Hello Aram,

i am trying to deal with the Docs the whole time, but now i am stuck.

Let me Explain what i have now.

The LocationSubmission is:
The Page where i submit my Locations on the Frontend, they are saved into the DB.
Files are created: LocationSubmission.php and

The Page Locations:
This is the Holder Page, where ALL Locations are listed, but only an Overview.
with a Link i want to go deeper to the DetailPage wich is "Location".

The Pages "Locations" and "Location eintragen" are created with the CMS.

You can see the Pages here:

"Mehr" is more for the Link to the Details.

Am i better in my Description now? :)


13 March 2009 at 6:52am Community Member, 21 Posts

Tell us, what do you mean by "custom" table?
Is it build without using silverstripe's database builder tool?


13 March 2009 at 7:41am Community Member, 44 Posts

I Created the Table with PHP File within "mysite/code" to store the Forminserts.


13 March 2009 at 8:04am Community Member, 21 Posts

Sorry, I do not understand the meaning of your words.
Please post the content of that file.


13 March 2009 at 8:06am Community Member, 44 Posts

   class LocationSubmission extends DataObject {
      static $db = array(
         'Name' => 'Varchar(200)',
         'Author' => 'Varchar(100)',
         'Email' => 'Varchar (100)',
         'Description' => 'Text',
         'Adress' => 'Varchar(150)',
         'PLZ' => 'Int(5)',
         'Location' => 'Varchar(50)',
         'Country' => 'Varchar(50)',
         'Table' => 'Varchar(150)'



And the FolderStructure attached as an Image.

Thank you.

Attached Files

13 March 2009 at 8:31am Community Member, 21 Posts

What you are doing there is defining an object with the attributes it will have and where to store them.
Now you can get each attribute in your view like you did with:
<% control LocationShow %>

<% end_control %>

This calls the method LocationShow of your LocationHolder class.

LocationHolder per Definition is the Holder for the children.

You defined the children using:
static $allowed_children = array(
in you LocationHolder class.

This means objects of type Location will be stored in the Holder class.

Tell me, what does your definition for the Location object look like?
Please post the code.


13 March 2009 at 8:37am Community Member, 44 Posts

Currently the Location.php ist empty or has just this one:


   class Location extends Page {

   class Location_Controller extends Page_Controller {



BUT - the $Link in the is empty.
I dont get it. :(