neildaemond Posted December 17, 2012 Share Posted December 17, 2012 I'm creating a service which sells something like a subscription to a product. First, someone inputs their preferences, then if they are not logged in the preferences are saved to session variables while the user is prompted to sign up or login. Upon sign up, the session preferences will be used to create an order for the subscription. This order is actually just a page created as a child of the user, using the 'order' template. I've managed to create the child page of the user by making its parent equal to $user. However, I want to list out all the user's orders but I don't think I'm doing it properly. making the 'order': $b = new Page(); $b->template = 'order'; $b->parent = $user; $b->name = 'order' . $b->created ; $b->title = 'Order For '.$session->order_name ; $session->order_name = ''; $b->save(); trying (but failing) to list out the orders: foreach($user->children() as $order){ echo $order->name; } How can I make it so a user can view their child pages? or is it just a bad idea to make these orders as children of the $user? Should I instead just create orders under a page(directory) named /orders/ ? how would I protect those? the $user is not a superuser, nor does it have any associated roles yet. perhaps I need to give them a role and allow that role access the page? however, that may give all users with that role access to pages which aren't theirs. Maybe i need to use that module which allow user access to one page(i havn't tried yet). I will try these guesses first... Thanks in advance for any advice, Link to comment Share on other sites More sharing options...
diogo Posted December 17, 2012 Share Posted December 17, 2012 I dropped your code as is on my testing install, and it worked well. Only thing that changed was that I used the "basic-page" template instead of your "order", that i don't have obviously. So I'm guessing it might be something with the template access settings? Link to comment Share on other sites More sharing options...
neildaemond Posted December 17, 2012 Author Share Posted December 17, 2012 Thank you diogo. I ended up adding the page-edit-per-user module. after adding the child page as an editable page, it shows up I guess the $user didn't have the proper access rights. now to add the editable page using the api... its probably just as easy as changing a field Link to comment Share on other sites More sharing options...
Soma Posted December 17, 2012 Share Posted December 17, 2012 Probably ur child pages are only found if you add include=all to the children() . to list pages a user dont need access or edit rights to list pages. 1 Link to comment Share on other sites More sharing options...
neildaemond Posted December 17, 2012 Author Share Posted December 17, 2012 Probably ur child pages are only found if you add include=all to the children() . to list pages a user dont need access or edit rights to list pages. you are right! whoops, mine was only working because I was still logged in as the admin after adding the module 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