Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS?

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 2 3 4
Go to End
Author Topic: 6672 Views
  • DaAmazing1
    Avatar
    Community Member
    2 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    To disable the rendering of the HTML try this, it worked for me. Someone else confirm this is right, I just started hacking the code two days ago so I might be missing something.

    In the Saphire/core/Model/Hierachy.php file you'll find a getChildrenAsUL function line number 37. If you insert after

    foreach($children as $child) {

    these lines of code

    if(!$child->canEdit())
    continue;

    the HTML for the tree nodes won't render.

  • erwanpia
    Avatar
    Community Member
    63 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    @DaAmazing1 : works fine.

    doesn't solve my problem of subpages though...

  • DaAmazing1
    Avatar
    Community Member
    2 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    After further research that was a pretty bad solution, that class is used to decorate other classes so who knows what gets broken by doing that. I found a better easier solution that solves the html rendering and the subpages:

    In the cms/code/LeftAndMain.php on line number 388 you'll find a $sitetree variable being set, change that to this:

                $siteTree = $obj->getChildrenAsUL("", '
                      ($child->canEdit()?"<li " . ($child->canEdit()?"id=\"record-$child->ID\"":"") . " class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
                      "<a href=\"" . ($child->canEdit()?Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID):"javascript:;;;") . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"' . _t('LeftAndMain.PAGETYPE','Page type: ') . '".$child->class."\" >" .
                      ($child->canEdit()?($child->TreeTitle()):"&nbsp;") .
                      "</a>":"")
       '               "</a>"
       '

    This is a better solution because your not messing with the core code and should only affect the Sitetree. All the decorator Hierarchy class does a simple php eval on the template so the inline ifs should solve the issue. The tree looks a bit messed up, but everything works I'm sure you guys can figure out a way to hack the css to fix the tree. Also the code is a bit messy I was trying several different things so you might want the extraneous inline ifs deleted.

  • erwanpia
    Avatar
    Community Member
    63 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    well done, I have not tested your code but had looked at this line of code and tried to implement what you did, this is exactly the place to make this modification happen

  • Ricardona
    Avatar
    Community Member
    26 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    I have tested your code and works!

    Is possible add this to SS distribution?

    Thanks that is perfect for me.

  • PP
    Avatar
    Community Member
    5 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    yes, we've been using that code since January and it's worked perfectly =)

  • erwanpia
    Avatar
    Community Member
    63 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    hi, quick note on upgrade for 2.3.2, change occurs in cms/code/LeftAndMain.php : line 517

    $siteTree = $obj->getChildrenAsUL("", '
                   ($child->canEdit()?"<li id=\"record-$child->ID\" class=\"" . $child->CMSTreeClasses($extraArg) . "\">" .
                   "<a href=\"" . Director::link(substr($extraArg->Link(),0,-1), "show", $child->ID) . "\" class=\"" . $child->CMSTreeClasses($extraArg) . "\" title=\"' . _t('LeftAndMain.PAGETYPE','Page type: ') . '".$child->class."\" >" .
                   ($child->TreeTitle()) .
                   "</a>":"")

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS? Link to this post

    Great, thanks Erwanpia. This should really get considered for the core, are there any relevant tickets open?

    6672 Views
Page: 1 2 3 4
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.