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

Hidng Site Tree Pages and Tabs in the Editor Content View of the CMS?


Reply

26 Posts   6831 Views

Avatar
DaAmazing1

17 January 2009 at 4:21pm (Last edited: 17 January 2009 4:22pm), Community Member, 2 Posts

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.

Avatar
erwanpia

18 January 2009 at 3:06am Community Member, 63 Posts

@DaAmazing1 : works fine.

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

Avatar
DaAmazing1

18 January 2009 at 6:20am Community Member, 2 Posts

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.

Avatar
erwanpia

22 January 2009 at 12:38am Community Member, 63 Posts

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

Avatar
Ricardona

9 June 2009 at 1:42pm Community Member, 26 Posts

I have tested your code and works!

Is possible add this to SS distribution?

Thanks that is perfect for me.

Avatar
PP

10 June 2009 at 12:30pm Community Member, 5 Posts

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

Avatar
erwanpia

30 July 2009 at 9:25pm Community Member, 63 Posts

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>":"")

Avatar
Carbon Crayon

30 July 2009 at 9:58pm Community Member, 598 Posts

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