Jump to:

5513 Posts in 1732 Topics by 1218 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Hiding pages in site tree and adding list of children pages to tab

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

Page: 1 2 3 4 5
Go to End
Author Topic: 6171 Views
  • schellmax
    Avatar
    Community Member
    126 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    there was a method Director::get_site_mode() which returned a string ('cms' or 'site'), but it seems to have been deprecated in 2.4: http://open.silverstripe.org/changeset/80055/modules/sapphire/trunk/core/control/Director.php
    unfortunately i can't find a replacement for this...

  • pter
    Avatar
    Community Member
    38 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    *smile* Yep, the Director class was the first place I looked, followed by a rummage in the cmsmain/leftandmain and the rest but couldn't spot anything obvious. Had look at the Director code "deprecated as no longer necessary". I beg to differ (O:

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    You could try grabbing the current controller and check if it extends LeftAndMain. If it does you're in the admin area.
    Try something like

    is_subclass_of(Controller::curr(), "LeftAndMain")

  • pter
    Avatar
    Community Member
    38 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    Hmm. That is still taking just as much of a chance as my own hack. It would be nice to have an official method. I say this as the augmentStageChildren approach seems to be an approved way of extending (as usual feel free to correct me!) and is active in both web page delivery and CMS aspects where, as demoed here, you might want to have more than one behaviour based on what is going on. That said I must say I am still having fun with SS, even that includes more than a few late nights.

  • pter
    Avatar
    Community Member
    38 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    Gotta get a proper method to determine CMS vs web delivery as I am finding this augmentStageChildren very handy. While I wait patiently for an approved and maintained method to 'how to tell if in CMS or displaying web page' you can amuse yourself with this wee piece of code based on the same approach:

    By default pages in sidebars, menus and the rest get sorted in the order they appear in the CMS, unless you have a specific page control to do otherwise. If you have a lot of pages and desire alphabetical order on any random page or chunk of tree in the site (for example a list of people) it can become a pain to shuffle them all around in the CMS. IMO it can also be easier for people to find something if they know the list is in order.

    Enter 'SortChildren'. I've implemented a SiteConfig decorator to provide site wide default settings and a SiteTree decorator that inherits or starts a new set of settings for a page and its children. Settings being whether to sort children alphabetically, leave in CMS order, or reverse sorting. With blocking and inheritance (i.e. the changed page becomes the new default for all pages below). It of course does need to know when it is in the CMS or not because it only want to do it for output. Although having written that I've just thought... wonder what would happen if it had an option to sort the CMS pages so they always end up alphabetical? Crash and Burn?

    I'm starting to think this might be used to implement the 'only show what they are allowed to edit BUT also show minimal path of non-editables to' in the CMS based on "is allowed to edit object? no... but does it have a child they can? yes then keep it otherwise don't". That could be a nasty load generator for when able to edit heaps, but could also be set to not process for admins or users with a Permission. For other more constrained users who can only work with a handful of items and assuming the site tree isn't too deep it might speed things up.

    And please please don't tell me that augmentStageChildren is going to be deprecated (O"

    [[ FILE REMOVED LATER VERSION IMPLEMENTING SMURKAS' CHECK BELOW ]]

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    Well yes it's as risky as your own check and the check I suggested makes alot of sense. All the CMS areas inherit LeftAndMain so checking for it makes sense. I don't think there's one approved way of checking if you're currently in the CMS so I think you're going to have to settle either for your own solution or some other non deprecated way of finding out if you're currently in the CMS.

    I'd just make sure that whatever method you choose to use doesn't run the risk of generating false positives.

  • pter
    Avatar
    Community Member
    38 Posts

    Re: Hiding pages in site tree and adding list of children pages to tab Link to this post

    Fair comment and I've switched to your suggested method. But still waiting to see if any non deprecated method exists.

    Oh and out of amusement I added a toggle in sort children to see what would happen if it was allowed to sort the CMS (put in switch at SiteConfig level). Which isn't that silly really as it makes working with piles of user profile pages much easier as you can (as mentioned in a previous post) quickly scan an alpha sorted list to see if the entry is there and don't have to worry about, e.g, dragging/dropping new user pages into the correct name of person order.

    Attached Files
    6171 Views
Page: 1 2 3 4 5
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.