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

Using existing MySql Table for content


Go to End


4 Posts   791 Views

Avatar
tomduncan

Community Member, 2 Posts

19 November 2014 at 11:35am

Hi All,
put this is the Data module area.
Must be wrong place. Any here it is again.

I am a new person to and SilverStripe.

I have an application that has recipes (as in food)
This is in a single mysql database at the moment.
1. With fields like Course
2. Name of recipe
3. Ingredients needed
4. How to cook
5. Time to prepare
6. comments

What I would like to do is first create a list of courses.
Then when selected it will then show the names of the recipes that meet that requirement.
Then select which recipe which will show it.

Seems simple, I hope.

Can someone give me an idea on how to use the data. I will copy the table into the SilverStripe database.
Or do I need to import the data?

Also at a later stage have login to the area within my site and availability for a user to add a recipe.

Any ideas?

Tom Duncan
Australia

Avatar
martimiz

Forum Moderator, 1391 Posts

20 November 2014 at 1:50am

If you're new to SilverStripe, you might want to look at the tutorials first, because they will give you some insight in the SilverStripe datamodel - including DataObjects, Pages and datatables and how they all work together.

http://doc.silverstripe.org/framework/en/tutorials/

After going through the tutorials, you'll probably want to build something like:

- a Recipe DataObject
- a Course DataObject
- a RecipeOverview page
- a RecipePage
- a RecipeSearchPage

Silverstripe DataObjects will create their own datatables in the database and you cannot just use your own table, so you'll have to import the data in some way.

Avatar
swaiba

Forum Moderator, 1899 Posts

20 November 2014 at 2:37am

I wouldn't normally criticize the wonderful martimiz - however I think that one issue with silverstripe is that people do extend pages, instead of using dataobject. So I would suggest that you focus on using DataObjects only and then make pages that loosely connect to that data*

*note this is a personal preference and many modules, user clearly disagree but still I've said it

Avatar
martimiz

Forum Moderator, 1391 Posts

20 November 2014 at 4:09am

@Swaiba: hahaha packaged nicely with a bow on top :)

Elaborating on the list in my first post:

- a Recipe DataObject
This is your actual Recipe containing all the data, managed in ModelAdmin

- a Course DataObject
Also managed in ModelAdmin: available courses, related to the Recipe in a many_many relation, as one recipe could count as lunch as well as eh.. breakfast?
Note: this could also be an enum field in the Recipe object, if you want to keep things simple, or a comma-separated textfield or...

- a RecipeOverview page
Pagetype to highlite favorite or new or seasonal recipes. Some sort of homepage thingy

- a RecipePage
Pagetype to display the selected Recipe in one way or another

- a RecipeSearchPage
PageType where you enter search criteria to find all breakfast dishes with squid as the main ingredient and display the results

That's probably what I meant :) (and I type too much today)

Martine