Robin S Posted December 17, 2015 Share Posted December 17, 2015 I have a page "go" using template "go" that I use for adding/updating pages via the API - I visit mysite.com/go and my code executes. It's convenient to keep this page in the tree so it's there when I need it but I worry about it being accidentally accessed (by me!), so I want a way to disable the page when I'm not using it. I thought unpublishing the page would do it, but it seems that the template code executes on visiting mysite.com/go even when the "go" page is unpublished. Is there a way to disable a page so it's template code does not execute? I'm also interested to learn other techniques that can be used to execute API code besides putting it in a template and accessing it from the frontend. Link to comment Share on other sites More sharing options...
Wanze Posted December 17, 2015 Share Posted December 17, 2015 You can still visit unpublished pages when logged in as superuser, that's why your template code gets executed. If you want to handle via this via unpublished status, simply add this on top of your template file: if ($page->isUnpublished()) { throw new Wire404Exception(); } ... or if you want a message remembering yourself that you need to unpublish the page, instead of a 404, echo out something and return Cheers 1 Link to comment Share on other sites More sharing options...
Robin S Posted December 17, 2015 Author Share Posted December 17, 2015 Perfect, thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now