Jump to:

22999 Posts in 11854 Topics by 2828 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: 6412 Views
  • Soft
    Avatar
    Community Member
    3 Posts

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

    I know that this thread is kinda old but afaik this is still an issue for some. At least it was that for me, I made a site were many different users, resellers in this case need to edit their own part of the site without any insight in the other resellers sites. Including the Site Content and Files & Images.

    The solution presented earlier in this thread works great for the Site content view, but I had to take it one step further in order to prevent the resellers from viewing each others uploaded files.

    Based on the earlier solutions I made a little more general solution that have worked really good for me so far. Including all file browsing i file views etc. It will also solve the ul/li formatting issues.

    Only need to edit getChildrenAsUL method in sapphire/core/model/Hierarchy.php
    (Changes marked in red)

    public function getChildrenAsUL( ... ) {
       if($limitToMarked && $rootCall) {
          $this->markingFinished();
       }

       if($this->owner->hasMethod($childrenMethod)) {
          $children = $this->owner->$childrenMethod($extraArg);
       } else {
          user_error(sprintf("Can't find the method '%s' on class '%s' for getting tree children",
             $childrenMethod, get_class($this->owner)), E_USER_ERROR);
       }

       if($children) {
          if($attributes) {
             $attributes = " $attributes";
          }
          

          $anyChildEditable = false;
          foreach($children as $child)
          {
             if ( Object::has_extension((string)Extension::get_classname_without_arguments($child),'ResellerEditRights') ? $child->canEditCMS() : $child->canEdit() ) {
                $anyChildEditable = true;
                break;
             }
          }

          $output = "";

          if ( $anyChildEditable )

             $output = "<ul$attributes>\n";
          
          foreach($children as $child) {

             if ( strstr($titleEval, 'Object::has_extension') === FALSE )
             {
                $titleEval = '( (Object::has_extension((string)Extension::get_classname_without_arguments($child),"ResellerEditRights") ? $child->canEditCMS() : $child->canEdit()) ?' .
                   $titleEval .
                ':"")';
             }

             
             if(!$limitToMarked || $child->isMarked()) {
                $foundAChild = true;
                   
                $output .= eval("return $titleEval;") . "\n";

                $childOutput = $child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod, false);
                if ( strlen($childOutput) > 0 )
                   $output .= $childOutput . "</li>\n";

             }
          }
             

          if ( $anyChildEditable )

             $output .= "</ul>\n";
       }
          
       if(isset($foundAChild) && $foundAChild) {
             return $output;
    }

    Looks a little messy but if you look closely it's not that bad.
    For some reason some classes didn't allowed me to override the canEdit() function. I solved this by first checking if the ResellerEditRights is present and then use the custom method canEditCMS() instead.

    Hope it helps to solve any issues you have, or to make a better solution (maybe more stable not to sure about this one yet)

  • 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

    Soft this is really useful, please open ticket for include in SS distribution

    6412 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.