3093 Posts in 875 Topics by 654 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1321 Views |
-
Is everything in SilverStripe a Page?

16 December 2009 at 6:03am
I'm in the process of scoping out quite a few web frameworks and content management systems for a website I'm maintaining. As I don't have enough time to test each one as thoroughly as I would like, I was hoping I could get some insight here. I did some experimenting myself after reading the documentation, but I still didn't find an answer to my question:
Is everything in SilverStripe a Page? More specifically, if I want to display something on the site, does my custom class have to extend the Page class?
My website has relatively few ordinary "pages"; it's more of a "traditional" database, so to speak: I've got albums, songs, producers, and so on, none of which are really pages (they don't have a "content" field, and they don't have comments, for example).
I tried creating all these classes and having them extend the DataObject class, but then they didn't show up in the dropdown list next to the "Create" button. In another thread, I also read that DataObjects don't have their own URLSegment, which makes it impossible to give a DataObject its own page (which is essential for my site).
Essentially, what I'm trying to create is a discography, among other things, more like a database than a collection of "pages." Given all of the above, is SilverStripe suitable for what I'm trying to do?
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 8:09am
Everything that shows up in the left-hand menu in the Site Content area is a Page. However, a Page is just an extension to DataObject.
What might be best for your situation is to create a ModelAdmin interface to manage your albums/song/producer DataObjects. You can that create a quick custom controller to allow you to access these by ID - e.g. /albums/ID, songs/ID.
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 9:03am
Also to extend what ajshort has said - check out the 5th tutorial - http://doc.silverstripe.org/doku.php?id=tutorial:5-dataobject-relationship-management this explains a process without 'pages' more akin to a database structure. This uses relationships and ComplexTableFields.
ModelAdmin is also a great way to easily manage objects like albums, artists - http://doc.silverstripe.org/doku.php?id=modeladmin
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 9:26am
So I should represent all of my data using DataObject classes, and then display them using Page and a corresponding Page_Controller? (Or is that PageHolder and PageHolder_Controller?)
When you say I can access the DataObjects by ID, do you mean a necessarily numeric ID? Can I access each object using a string as well?
Finally, is there any advantage to representing something as a DataObject rather than a Page?
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 9:49am
Finally, is there any advantage to representing something as a DataObject rather than a Page?
Well a page is a fancy dataobject with built in functionality for being in the 'SiteTree'. You get the benefit of the page functionality but also the overhead.
When you say I can access the DataObjects by ID, do you mean a necessarily numeric ID? Can I access each object using a string as well?
You can but usually ID's are easier to validate since they are numbers. You could generate your own slug field on the dataobject and query the db on that but using ID's you can get away with something like
mysite/code/Page.php > Page_Controller
function album() {
$album = DataObject::get_by_id("Album", Director::urlParam('ID'));
return $this->customize(array('Album' => $album));Then you should be able to do something like /page/album/2 and use <% control Album %> in the template. If you wanted to use a string then you would need to change the get_by_id to a get and change the 2nd parameter to query the correct column
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 10:36am
I see. In that case, is SilverStripe still what I'm looking for or is the "get by string" technique somewhat of a hack and I'm really looking for something else to manage this database-centric site?
(What I'm most impressed with about SilverStripe is the advanced automatically-generated CRUD interface—especially with the DataObjectManager module—which is why I'm interested in SilverStripe specifically.)
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 10:49am
"get by string" technique somewhat of a hack and I'm really looking for something else to manage this database-centric site?
No its not a hack at all. We just like to make it easy by using numbers for example this forum. I've used slugs before See http://jobs.silverstripehq.com/positions/job/enhanced-e-commerce-module - that job is a dataobject with a generated slug for the title so it does something like
DataObject::get_one('Job', "Slug = '". Convert::raw2sql($url) . "'");
You just need to be more careful for generating valid URLs and doing any database work to make sure you escape / convert the strings.
-
Re: Is everything in SilverStripe a Page?

16 December 2009 at 10:59am
Alright, thanks! As mentioned, SilverStripe looks promising so I'll try it out some more. If I like everything else about it, you may well be seeing me around here again in the future.
| 1321 Views | ||
|
Page:
1
|
Go to Top |



