ziu Posted November 15, 2017 Posted November 15, 2017 Hi i created a custom admin page and i just want to know is there a module or any way to show a user only those pages under subpages of a page in tree which he has created. please help.
adrian Posted November 15, 2017 Posted November 15, 2017 @ziu I think this is what you are looking for, but not positive of your exact scenario: http://modules.processwire.com/modules/admin-restrict-branch/ 1
ziu Posted November 15, 2017 Author Posted November 15, 2017 thank you adrian, i am trying this module and will update you regarding this. thanks again
ziu Posted November 15, 2017 Author Posted November 15, 2017 i used that module but its not what i was looking for, i have below mentioned pages. Properties (parent template) ---Property 1 created by admin ---Property 2 created by user1 ---Property 3 created by user1 ---Property 4 created by admin ---Property 5 created by user1 But i when 'User1' login to his account-- i want to show only those pages which he has created. like below Properties (parent template) ---Property 2 created by user1 ---Property 3 created by user1 ---Property 5 created by user1 Thank you, any help will be appreciated.
adrian Posted November 15, 2017 Posted November 15, 2017 It sounds like easiest approach would be to change it to look like this: Properties ---User 1 -------Property 1 -------Property 3 ---User 2 -------Property 2 -------Property 4 I understand that might be an issue for the url structure on your site. There are ways around this though. The other option is https://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/?do=findComment&comment=84916 - read that post and the post that it links to and the rest of both threads. There are ways to do this that should work fine and in your scenario I don't think the mentioned problems will be an issue. Let us know if you need help with any of the linked scripts. 2
ziu Posted November 15, 2017 Author Posted November 15, 2017 Thank you adrian, you are so quick, thanks alot, i guess the links you shared can possibly solve my problem and i am also thinking about the way you presented the paging approach. thank you. will update you soon. 1
ziu Posted November 16, 2017 Author Posted November 16, 2017 @adrian hi , can you show me the right way to use 'createdUser' api , i want to match this with the logged in user so that i can display those pages only which has been created by the same user who is loggedin. thank you
adrian Posted November 16, 2017 Posted November 16, 2017 2 hours ago, ziu said: @adrian hi , can you show me the right way to use 'createdUser' api , i want to match this with the logged in user so that i can display those pages only which has been created by the same user who is loggedin. Well, it's pretty much just like this. If the createdUser property for the given page matches the current user, it will return true, otherwise false. If that doesn't make sense, maybe post some code so we can debug for you. 2
ziu Posted November 17, 2017 Author Posted November 17, 2017 i have created a custom admin page which shows pages of a template only... below is the code, but i want to show only those pages that are created by the login user. as i already tried other solutions you mentioned above, but i am totally confused that, how can display those pages. <?php $u=$user->id; $this->modules->get('JqueryMagnific'); //render PageListtree with setting the parent page $formImages = $this->modules->get('InputfieldForm'); // prep the form $wrapperImages = new InputfieldWrapper; // a wrapper $wrapperImages->attr('value', '<h2>Artist Registration Page</h2>'); $i = $this->modules->get('ProcessPageList'); // here i want to display only those subpages which matches to the user logged in $i->set('id', 5845); // setting the parent page $pageTreeImages = new InputfieldMarkup; // the placeholder $pageTreeImages->value = $i->execute(); // fill the InputfieldMarkup form field... $wrapperImages->add($pageTreeImages); // put inside the wrapper... $formImages->append($wrapperImages); // append the wrapper ?>
adrian Posted November 17, 2017 Posted November 17, 2017 Have you tried this gist: https://gist.github.com/adrianbj/e391e2e343c5620d0720 With this PW permission: I haven't tested, but I think that combination should work as is, or with a little tweaking. Might avoid you needing to reinvent things. 1
Robin S Posted November 17, 2017 Posted November 17, 2017 To hide pages from ProcessPageList for non-superusers (doesn't apply for superusers) you can hook Page::listable(). $page->listable() bool Returns true if the page is listable by the current user, false if not. Can also be used as property: $page->listable So to hide pages that the user cannot edit you can add this to /site/ready.php: $wire->addHookAfter('Page::listable', function(HookEvent $event) { $page = $event->object; if(!$page->editable) $event->return = false; }); 1
adrian Posted November 17, 2017 Posted November 17, 2017 Some discussion on this and using listable() https://github.com/ryancramerdesign/ProcessWire/issues/302
ziu Posted November 18, 2017 Author Posted November 18, 2017 I will definately try these solutions, thank you @adrian and @Robin S.
ziu Posted November 18, 2017 Author Posted November 18, 2017 hi @adrian that worked , now user can edit only those pages which he has created, but user still can see all other pages, can't we do anything to hide other pages that he has not created in list, i already tried to use higepagesuser module, but thats not working. Help
ziu Posted November 18, 2017 Author Posted November 18, 2017 @adrianyour hideotherpages and hideuneditable modules works like charm, but i used createdUser->id with User->id to match and show only those pages which a user has created. Many thanks to adrian, i really appreciated the way he reponds. 1
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