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.

All other Modules /

Discuss all other Modules here.

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

I can't handle sub-URLs of a CMSMain object


Reply


5 Posts   581 Views

Avatar
Ihateit

Community Member, 4 Posts

6 October 2011 at 2:04am

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.

Avatar
MarcusDalgren

Community Member, 288 Posts

6 October 2011 at 2:20am

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

Avatar
Ihateit

Community Member, 4 Posts

6 October 2011 at 2:38am

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;
            }
         }

Avatar
MarcusDalgren

Community Member, 288 Posts

6 October 2011 at 2:44am

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?

Avatar
Ihateit

Community Member, 4 Posts

6 October 2011 at 2:49am

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.