Jump to content

onjegolders

Members
  • Posts

    1,147
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by onjegolders

  1. The issue is when using the ProcessPage Delete non-core module. It adds a link to the page so you can delete without entering the page itself. I will have a look at the update function again. I was testing with $page->isChanged() but it's still trying to update the user even if there were no changes to the page. Strange. if($page->template == 'student' && $page->isChanged()) { Thanks for the explanation about skip.
  2. I absolutely love this theme, thanks for the excellent work. We're using a slightly modified version of this on all our sites. (Only removed the sidebar "latest" section as we wouldn't make great use of that part.) Looks great, thanks again, Nikola
  3. Thank you very much Soma. That's brilliant and it's got it working for me. I was still having an issue but I think it's related to the ProcessPageDelete module as when I go into Edit->Delete it works perfectly. I have a couple of questions if you could explain? 1. Is the "save" hook appropriate for page updates as on page deletes it is also triggering the message from my update function. 2. Could you explain what $page->skip is used for? I can't find that anywhere and I have no idea how I would have ever figured that out without your input! Thanks again
  4. Even if I hardcode it, it doesn't seem to work unless there is an issue with my selector Thank you Kongondo for testing this, I really appreciate it. I wonder what we're missing here...
  5. Thanks Soma, you're absolutely right. I am learning though I do have messages at each point of this process. For some reason it's not finding the user. Could it be something to do with users not being accessible here?
  6. Thanks Soma, I have tried changing the hook to trash but unsure whether I should be hooking before or after. I think the name gets changed when moved to trash. Something like 1234_pagename.
  7. Another update. I'm now wondering whether even the core uses delete as it's own function or whether it's encompassed in the page edit functionality? In the core module it checks to see if an input with a name of submitted is submitted and then it processes the delete. Strangely this is relatively straight forward in the front end. 1) Get the user whose name is the same as the page 2) Delete user. I'm wondering if I'm approaching this wrong as I've never really created PW modules before.
  8. Thanks anyway Valery, it's useful having different thoughts on it! I just imagined that as it's part of the core there must be some expected behaviour in this scenario.
  9. I think it comes down to user preference as Diogo says. Some people would rather have things streamlined by default rather than drowning under contextual menus. Most projects tend to be a combination of design and functionality and more often than not one side is stronger than the other. I think this shows through from the screenshots. Well designed applications tend to make the experience more pleasurable and conversely if something doesn't feel "right", then the user isn't going to stick around long enough to figure out that there's a button in a submenu that does X, Y or Z. EDIT: I'm not "liking" anything more Diogo says. He has too many likes already. The greedy so-and-so.
  10. Something on the updateTheUser function is also creating errors when trying to delete the page. Strange.
  11. Thanks Valery. I think I should specify, I'm adding the password field to a different page and adding the required value myself in the file settings. Essentially it's so that my client can create a "member" while also creating a user without having to also remember to go to Access->Users and add one there. Ideally the password field would be required initially when they add the page but perhaps thereafter not required. Either that or the value of a password field on the edit page template should not be empty.
  12. Thanks Valery, yes this is in the backend. On page save, the required error still gets called even if previously a password has been set. This must be because the password field is empty and it's only if a user fills it in that it gets reset.
  13. Thanks Diogo, I tried that but am still getting a NullPage error on delete. Interestingly the page does end up in the trash though but the user doesn't get deleted. Did you mean is this user the logged-in user? No, this would only be for guest users.
  14. Actually I spoke too soon, that wasn't it I changed the variable name then left it on the $page = $event->arguments[0] lines so it wasn't even being called. Which is why the pages were getting deleted OK but the actual user creation wasn't working!
  15. Thanks Martijn but that didn't change things. Interestingly, if I comment out the delete function I'm still getting the errors. Is it possible the hooks for page save and page add are still running on page deletion? (I can't think why?) Ahhh! Think I have it, I was reusing the $event variable, I changed it to $event1, $event2, $event3 and it now seems to function. Is that right?
  16. Hi Martijn, no it doesn't (not that I'm aware of). It's a standard PW user.
  17. I agree Sevarf, Diogo built a custom admin pages module which I haven't tried but I like the simplified approach you're advocating.
  18. WeBuilder's functionality does look mighty impressive. It's just. It's just. It looks kinda ugly.
  19. Is the password field compatible with the "required" option? I only ask because if I make it a required option when editing a page if I haven't changed the password, it throws a required error. Obviously I'd like for the user to be able to leave it blank and leave the password how it is. The problem is if I don't make it required then I may end up without a password at all. Is this something I should look to triggering via a module? Thanks.
  20. Hi again fellow PWers, A while back I created a newUser module that added a new user when a page (student) was added. This all works great. Today I'm trying to add a delete function to this same module (as we were getting leftover users when students were deleted) but it's throwing NullPage errors. I tried changing the hookAfter to hook Before but am still getting errors. Also strangely it's causing an issue when trying to delete these pages from the trash. I'm getting a "this page cannot be deleted" error. Any pointers would be greatly appreciated ------------------------------------------------------------ <?php class Createnewuser extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'Create a new user', 'version' => 101, 'summary' => 'Creates a new user and edits an existing member on saving a member page.', 'singular' => true, 'autoload' => true, ); } public function init() { $this->pages->addHookAfter('added', $this, 'createTheUser'); $this->pages->addHookAfter('save', $this, 'updateTheUser'); $this->pages->addHookBefore('delete', $this, 'deleteTheUser'); } public function createTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $newuser = new User(); $newuser->of(false); $newuser->name = $page->name; $newuser->pass = $page->password; $newuser->save(); $this->message("New user also added $newuser->name."); } } public function updateTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $the_user = $this->users->get("name=$page->name"); $the_user->of(false); if ($page->isChanged("password")) { $the_user->pass = $page->password; } if ($page->isChanged("email")) { $the_user->email = $page->email; } $the_user->save(); $this->message("User $the_user->name also updated."); } } public function deleteTheUser($event) { $page = $event->arguments[0]; if($page->template == 'student'){ $the_user = $this->users->get("name=$page->name"); $the_user->delete(); } } }
  21. Asana's great but if you don't have enough people using it properly it ends up being one of those things you drop and end up going back to more traditional means (pen & paper). I still hope to get there but it's hard pushing a system when the other people don't want to know
  22. *** You too mister!
  23. Sounds good. I just think it's one of those things (like ST itself) that's a bit involved to get things up and running but when you do it's brilliant.
  24. I never ended up using SFTP for ST2, just couldn't get my head around it. Found a nice alternative though was tying my local versions to live versions through Transmit and now I just press CMD-U and my local file gets replicated on the live version. Good list Valan, I can't imagine a better editor than ST for general coding though I suddenly am missing the simple theme from TextMate!
  25. This is brilliant Soma, thanks so much for all your time on it. I think it will be useful for everyone but can especially see some of the new users who often ask for examples finding this a great resource.
×
×
  • Create New...