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, Ed, biapar, Willr, Ingo, swaiba

Conceptual question: How to deal with one-off page types?

Go to End

2 Posts   1261 Views


Community Member, 7 Posts

24 March 2011 at 12:35pm

Edited: 25/03/2011 12:22am

Forgive me if this has been answered many times before, but I've been searching the web, the forums, SSBits, LeftAndMain, the SS book and so on for info on this and haven't been particularly lucky thus far.

The problem is basically: I am transferring a large-ish site (4.000 or so pages) to SilverStripe. In this process I'm implementing a series of sub-sections that deal with specific kinds of content that has certain presentational requirements that differ a lot from the 'ordinary' treatment of content.

One example of this is a sub-section of the site that shows information concering people and locations - names, photos, addresses and so on. This section has a front page with a search feature on it. I'm wondering how to implement a one-off feature like this without having to create a holder page type of which I only create one instance in the site tree.

While the holder-approach, which seems to be very common as it's described both in all the tutorials I've found and in the SilverStripe book, definitely is workable it seems quite inefficient to me when I'd like the section front pages to be based solely on controller logic as no DataObject is really required in these cases. As in: Why do I have to add yet another page type when I don't intend for content authors to create this 'magic' type of page in the future?

I *could* just create a class that extends ContentController and wire it in using Director::addRules, but then I don't get the benefit of the baked-in menu system and it seems to cause tons of trouble for me.

How do the more experienced developers deal with this type of problem? I suspect lots of sites must have one-off sections of which only one instance should exist, but how does one address this situation?

Thanks in advance! I'm loving SilverStripe a lot so far (coming from being forced into some Drupal coding that I'd rather forget about).

EDIT: Just want to add that I've done the canCreate() { return false; } trick on the page types I don't want others to create beyond the one instance I already made, but it still feels like a very clunky solution.


Community Member, 10 Posts

26 February 2012 at 7:18am

Edited: 26/02/2012 7:31am

I find this is a frequent decision I have to make, and I'm never quite sure the best option. Having a page-type does mean that there is flexibility provided in how the clients structure their site. If later on they decide that '/staff/view' should really be '/people/us/staff/view', then they can move your one-off page type. However, if they're not well informed, they can also delete it and break the site.

I use custom controllers for quite a lot of things. You do have to whip up a few functions now and then that you lose in the process. The advantage is FULL CONTROL, the disadvantage is a bit less flexibility in the site structure, and loss of a few helper functions.

I don't know if this makes your decisions easier -- it doesn't help me with mine! :)

- Lucas