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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

Query Data from a custom Table


Go to End


30 Posts   7889 Views

Avatar
slamby

Community Member, 21 Posts

13 March 2009 at 8:42am

You'll get it.

Think about your Location object. It is empty for the moment. No definitions.

Think about, what should be your detail page? Where should you define your detail page?
The link must be empty. Where should it point to?

Like you declared:
allowed_children = Location
But Location is empty, no definition.

Tell me your conclusions.

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 8:47am

I wish i could tell you my conclusion. I don't know where to go and what to do.

Would be very nice if you could help me out on the Link Problem and what to put into the Location.php

Thank you.

Avatar
slamby

Community Member, 21 Posts

13 March 2009 at 10:03am

I took a look at your site.
When I get you right, you like to show more details about what another user entered before in that form.

So your Location and LocationSubmission are the same. You only want to show part of the submitted data in the overview and with the more link you like to take the user to all details of the same recordset.

To get the more link working, it needs to point to an existing page. So you have to create a new page and a template for it. In the controller you need to grab the data from the database you like to show there again.

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 8:22pm

Hello Slamby,

you are right, yes.

I am sorry that it took so long to describe that stuff.

i created a Page "Location" or Better the Detailpage "Location".

There are 2 Questions now.

1. How should the link look like which points from the Overview to the Detailpage?
I would try it with: <a href="location/$ID">more</a>

2. As you said i need in the Controller of the Detailpage a DataObject to grab the Right Data from the Database.
Could you give me a Example how to achieve this?

I am very thankful for your help so far.

Thanks.

Avatar
Breastfed

Community Member, 44 Posts

16 March 2009 at 1:39am

Edited: 16/03/2009 2:25am

Slamby - could you help me here ?

I am totally lost - i am searching in the Docs but i can't find anything.
Would be very very helpful if you could give me some ideas how to create the more link and how to grab the data.

Thanks.

Avatar
Carbon Crayon

Community Member, 598 Posts

16 March 2009 at 3:08am

Edited: 16/03/2009 3:11am

Hi Breastfed

I think I uderstand what your are trying to do now :)

The problem you have is that your LocationSubmission is not a page, it is a dataobject table, so it does not have a link. You have the right idea with Location, but your implementations is slightly wrong. What you need the Location page to do is display the details from your LocationSubmission table by retrieving the appropriate row via the ID, which you can pass through the URL as a URL parameter.

So in your Location_Controller you need a funtion like this:

public function GetLocationSubmission(){

$Params = Director::urlParams(); //This gets our URLparams
$SubmissionID = $Params['Action'];  //gets the ID from our $Params array

return DataObject::get_by_id("LocationSubmission", "$SubmissionID");

}

So now Location.ss will act as your tempalte to view a LocationSubmission, so you will add something liek this:

<% control GetLocationSubmission %>
$Name
$Author
$Email
$Location
etc. etc.
<% end_control %>

Now all you need to do is pass the correct ID for the locationSubmission you wish to show as I think you were trying to do before. So the link on your LocationHolder will look something like this: location/$ID

Hope that finally gets you somewhere :)

Avatar
Breastfed

Community Member, 44 Posts

16 March 2009 at 3:32am

aaaaah!!!

Aram - thank you - it works now! :)

Peeeewwww... thank so much!

The LocationSubmission.php creates the Table for the Submissions, i have that structure from the Poll Tutorial.

How can i correct the stucture when i have to create a Table, create a Page with a Submit Form, a Holder Page and a detail Page?

This sitaution will be in my Projekt 2 more times, but i want to build i correct.

Thanks and many Thanks.

Avatar
Carbon Crayon

Community Member, 598 Posts

16 March 2009 at 3:41am

Well I think this is actually the correct way to do it, just using Location.ss as your template, it saves having to have a page in the CMS for each submission.

So I think if you jsut do it like this then you should be fine :)