Jump to:

23550 Posts in 19338 Topics by 2890 members

General Questions

SilverStripe Forums » General Questions » Conceptual question: How to deal with one-off page types?

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

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

Page: 1
Go to End
Author Topic: 892 Views
  • misterac
    Community Member
    7 Posts

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

    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.

  • Lucas
    Community Member
    10 Posts

    Re: Conceptual question: How to deal with one-off page types? Link to this post

    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

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.