bernhard Posted May 28, 2016 Posted May 28, 2016 hi, i have some settings under a page called /tools (for example /tools/default-mail-data-for-events or the like). i want all pages under this parent be hidden on the frontend so i came up with this: $this->addHookAfter('Page::viewable', $this, 'hideToolPagesFromFrontend'); /** * hide all pages under /tools from frontend access **/ public function hideToolPagesFromFrontend($event) { $page = $event->object; bd($page->closest('/tools')->path); if($page->closest('/tools')->id) $event->return = false; } the tabs should look like this: the tabs look usually like this: but when the hook is active all tabs except "content" are hidden: the dump is like this: why is page viewable called on every tab? how can i just hide the "view" tab? on frontend the functionality is as supposed...
Robin S Posted May 28, 2016 Posted May 28, 2016 Not really an answer to your question, but do these pages under /tools/ have template files? If no, they can't be viewed on the front-end. If yes and you are using them in other pages with $mypage->render() then you can make them not directly viewable by having this at the start of the template file: if(empty($options['pageStack'])) throw new Wire404Exception(); Apologies if this isn't helpful.
bernhard Posted May 28, 2016 Author Posted May 28, 2016 thank you robin, yes, they do have a template file, because its the same template i use on lots of other pages that have to be viewable on frontend. i fixed it quickly by putting this in my _main.php file: <?php if($page->closest('/tools')->id) throw new Wire404Exception(); pw is so awesome but i would prefer to understand whats going on and why viewable is called for every tab in the page editor ps: 700 posts... i'm getting old 1
LostKobrakai Posted May 28, 2016 Posted May 28, 2016 viewable() is called as part of fieldViewable() and that one is called at least for each FieldsetTabOpen. ps: 700 posts... i'm getting old They'll just get more and more 2
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