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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Calling controller function always delivers error 403


Go to End


14 Posts   3962 Views

Avatar
MarioSommereder

Community Member, 107 Posts

12 March 2015 at 9:43pm

@Nightjar All good.

@dhensby The documentation says: "If you're using the cms module with and dealing with Page objects then for your custom Page Type controllers you would extend ContentController or Page_Controller. You don't need to define the routes value as the cms handles routing." So this sould not be necessary in my case.

Avatar
Devlin

Community Member, 344 Posts

12 March 2015 at 9:53pm

So this sould not be necessary in my case.

This is correct.

When trying to load the function directly, the page says, that the page is not public yet and I have to log in as someone else to see the unpublished content.

Did you try to publish the page (again)? And maybe check the settings tab if you excluded the admin user.

Avatar
Nightjar

Community Member, 28 Posts

13 March 2015 at 12:43am

Edited: 13/03/2015 12:44am

@knsqnt Indeed the CMS handles routing, but only if your action is request at the end of the page itself (as opposed to site.com/Page_Controller). The * routing that automatically loads a controller of the request name was removed in... 4.0 (so not yet for stable releases - but check you're using 3.1 rather than master).

@dhensby
https://github.com/silverstripe/silverstripe-framework/blob/3.1/_config/routes.yml#L18

Avatar
MarioSommereder

Community Member, 107 Posts

17 March 2015 at 9:56am

Ok, Nightjar, I don't understand that. What do you mean with "at the end of the page"?

This is my framework/_config/routes.yml:

---
Name: rootroutes
Before: '*'
---
Director:
  rules:
    '': 'Controller'
---
Name: coreroutes
Before: '*'
After:
  - '#rootroutes'
  - '#modelascontrollerroutes'
---
Director:
  rules:
    'Security//$Action/$ID/$OtherID': 'Security'
    '$Controller//$Action/$ID/$OtherID':  '*'
    'dev': 'DevelopmentAdmin'
    'interactive': 'SapphireREPL'
---
Name: adminroutes
Before: '*'
After:
  - '#rootroutes'
  - '#coreroutes'
  - '#modelascontrollerroutes'
---
Director:
  rules:
    'admin': 'AdminRootController'

Looks good?

Another question: How cann I call a controller function via the URL? I installed a clean version of SilverStripe an it doesn't even work with a public function - added to allowed_actions - inside the Page_Controller.

Avatar
MarioSommereder

Community Member, 107 Posts

18 March 2015 at 10:33pm

Hm, seems like it just doesn't work locally. Are there any Apache settings I have to worry about?

Avatar
MarioSommereder

Community Member, 107 Posts

18 March 2015 at 10:51pm

Heureka! My VirtualHost was not configured correctly!

This changed everything:

<Directory /Users/knsqnt/Sites/usedsoft-newsletter/public/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
</Directory>

Thanks anyway for all you time! Really appreciated it!

Cheers, Mario

Go to Top