Jump to:

23375 Posts in 18175 Topics by 2866 members

General Questions

SilverStripe Forums » General Questions » Categorising

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: 673 Views
  • Harley
    Avatar
    Community Member
    153 Posts

    Categorising Link to this post

    Is it possible for me to categorize sub pages within the cms?

    To make things more specific, I have a client page I'm working on. Now these clients have to be categorized so I will have <b>Clients > Client category > Client</b>. This is pretty simple so far and works great but here is where it gets tricky. On my homepage I have a featured client which is randomized. This works great except, as you can see I have created a page for each client category, and because this is a child of 'Clients' it also shows up in the results.

    My question really is this:

    a. Can I somehow make each client category page unique so I can exclude this from my results in the sql?

    b. Is there another approach for categorizing content that I may not be aware of?

    Regards

  • Juanitou
    Avatar
    Community Member
    323 Posts

    Re: Categorising Link to this post

    Hi Harley,

    I think you need to delve into complex relationships between data objects (5th tutorial).

    If you create 1-to-many or many-to-many relationship between categories and clients, you could build a simpler to maintain web structure where, for example, you could create unique pages for every client where their categorie(s) data could be shown and a categories holder page with Category children displaying automatically corresponding clients, without requiring the creation of a Client subpage for every Category.

    Sorry about my English,
    Juan

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Categorising Link to this post

    You could just create a simple 'ClientPage' class, and use that:

    class ClientPage extends Page {
       
       static $db = array();

    }

    class ClientPage_Controller extends Page_Controller {

    }

    Now, in your page class you can do:

    // not particularly efficient method to select a ClientPage at random:
    function RandomClient() {
       $clients = DataObject::get('ClientPage');
       return $clients->getOffset(rand(1, $clients->Count()));
    }

    Since 'ClientPage' behaves in the same way as a 'Page', you can add them where ever you like and the RandomClient method will pick it up.

  • Harley
    Avatar
    Community Member
    153 Posts

    Re: Categorising Link to this post

    Thanks for your feedback Juanitou,

    The thing is, I need a seperate page for each client, each client will also have access to this page so they can themselves edit it. It's almost like a profile.

    Would it be possible to have a client holder, and then a category holder, then client page? Essentially two holders, one inside the other and then the client page?

    If I could somehow make the category page unique then that would be easier for me to manipulate.

    As I say it works great for me at the moment, but it is just the part on the homepage which has a featured client, by default it includes the category page as well which I don't want to happen.

    Regards

    673 Views
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.