Jump to:

10930 Posts in 2613 Topics by 1810 members

All other Modules

SilverStripe Forums » All other Modules » I can't handle sub-URLs of a CMSMain object

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 515 Views
  • Ihateit
    Avatar
    Community Member
    4 Posts

    I can't handle sub-URLs of a CMSMain object Link to this post

    Hey guys,

    i've just been told to add some text and images to a SilverStripe website. But when i want to add the image, i get this message: "I can't handle sub-URLs of a CMSMain object." I've triede some different fixes around the forum, but all of them 1+ years old, so they aren't quite working. What could be a workaround?

    Thanks

    //Anders J.

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: I can't handle sub-URLs of a CMSMain object Link to this post

    We need to see the code and know what version of SilverStripe you're running in order to help you.

  • Ihateit
    Avatar
    Community Member
    4 Posts

    Re: I can't handle sub-URLs of a CMSMain object Link to this post

    ss 2.3.6

    and as far as i can tell it's the RequestHandler.php, and i believe it's this:

          while($handlerClass && $handlerClass != 'ViewableData') {
             $urlHandlers = Object::get_static($handlerClass, 'url_handlers');
             
             if($urlHandlers) foreach($urlHandlers as $rule => $action) {
                if(isset($_REQUEST['debug_request'])) Debug::message("Testing '$rule' with '" . $request->remaining() . "' on $this->class");
                if($params = $request->match($rule, true)) {
                   // FIXME: This unnecessary coupling was added to fix a bug in Image_Uploader.
                   if($this instanceof Controller) $this->urlParams = $request->allParams();
                
                   if(isset($_REQUEST['debug_request'])) {
                      Debug::message("Rule '$rule' matched to action '$action' on $this->class. Latest request params: " . var_export($request->latestParams(), true));
                   }
                
                   // Actions can reference URL parameters, eg, '$Action/$ID/$OtherID' => '$Action',
                   if($action[0] == '$') $action = $params[substr($action,1)];
                
                   if($this->checkAccessAction($action)) {
                      if(!$action) {
                         if(isset($_REQUEST['debug_request'])) Debug::message("Action not set; using default action method name 'index'");
                         $action = "index";
                      } else if(!is_string($action)) {
                         user_error("Non-string method name: " . var_export($action, true), E_USER_ERROR);
                      }
                      $result = $this->$action($request);
                   } else {
                      return $this->httpError(403, "Action '$action' isn't allowed on class $this->class");
                   }
                
                   if($result instanceof HTTPResponse && $result->isError()) {
                      if(isset($_REQUEST['debug_request'])) Debug::message("Rule resulted in HTTP error; breaking");
                      return $result;
                   }
                
                   // If we return a RequestHandler, call handleRequest() on that, even if there is no more URL to parse.
                   // It might have its own handler. However, we only do this if we haven't just parsed an empty rule ourselves,
                   // to prevent infinite loops
                   if(!$request->isEmptyPattern($rule) && is_object($result) && $result instanceof RequestHandler) {
                      $returnValue = $result->handleRequest($request);

                      // Array results can be used to handle
                      if(is_array($returnValue)) $returnValue = $this->customise($returnValue);
                   
                      return $returnValue;
                      
                   // If we return some other data, and all the URL is parsed, then return that
                   } else if($request->allParsed()) {
                      return $result;
                   
                   // But if we have more content on the URL and we don't know what to do with it, return an error.
                   } else {
                      return $this->httpError(404, "I can't handle sub-URLs of a $this->class object.");
                   }
                
                   return $this;
                }
             }

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: I can't handle sub-URLs of a CMSMain object Link to this post

    The thing is though that there's probably something wrong with the code in the page type or data object that has the image. Please post that instead. Also, have you considered upgrading?

  • Ihateit
    Avatar
    Community Member
    4 Posts

    Re: I can't handle sub-URLs of a CMSMain object Link to this post

    Im just afraid an update will screw everything up. Cause i didn't build this site, so i don't know if it's going to break down when i update.

    I think i'm just going to give up. And tell 'em no.. Thanks alot for your willingness to help though. It's appreciated.

    //Anders J.

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