apeisa Posted December 9, 2011 Share Posted December 9, 2011 Users are just pages, but we can access them through $users. How is that done? I know that Users class extends PagesType, but I don't find anywhere how $users is created and how it filters that to include only pages with user template (or /access/users/ children). What I want to achieve is to have new $orders variable which is shortcut to $pages->find("template=order"). Link to comment Share on other sites More sharing options...
apeisa Posted December 9, 2011 Author Share Posted December 9, 2011 I think I found it: core/ProcessWire.php: <?php if(!$t = $templates->get('user')) throw new WireException("Missing system template: 'user'"); $users = new Users($t, $config->usersPageID); Wire::setFuel('users', $users); Link to comment Share on other sites More sharing options...
ryan Posted December 9, 2011 Share Posted December 9, 2011 To use PagesType, you have to specify a template and parent_id to the constructor. You actually don't need to extend PagesType unless you want to. I think you could achieve what you are wanting to do just like this: <?php $template = $templates->get('order'); $parent = $pages->get('/orders/'); $orders = new PagesType($template, parent->id); Link to comment Share on other sites More sharing options...
apeisa Posted December 9, 2011 Author Share Posted December 9, 2011 Thanks Ryan. I am doing this from autoload module, so it seems to require this too: Wire::setFuel('orders', $orders); It works nicely! 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