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
Carbon Crayon

Community Member, 598 Posts

13 March 2009 at 1:16am

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 LocationSubmission.ss.

Have a look through the tutorials to see how all this stuff works. http://doc.silverstripe.org/doku.php

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 1:39am

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 ...ss

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:

www.aerofunk.de/silverstripe/locations

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

Am i better in my Description now? :)

Avatar
slamby

Community Member, 21 Posts

13 March 2009 at 6:52am

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

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 7:41am

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

Avatar
slamby

Community Member, 21 Posts

13 March 2009 at 8:04am

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

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 8:06am

<?php
	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
Avatar
slamby

Community Member, 21 Posts

13 March 2009 at 8:31am

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 %>
....
$Name
$Description
$Adress
$PLZ

<% 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(
'Location'
);
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.

Avatar
Breastfed

Community Member, 44 Posts

13 March 2009 at 8:37am

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

<?php

	class Location extends Page {
	
	
	}


	
	class Location_Controller extends Page_Controller {
	

	
	}


?>

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