-
Posts
82 -
Joined
-
Last visited
FuturShoc's Achievements
Full Member (4/6)
32
Reputation
-
I'm building a custom application which will live inside ProcessWire. I'd like to use another framework to build the app, but I don't want to force the user to login twice (first with PW, then a second time for the custom application) So, I need to be able to run some code right after a user logs into PW using the standard admin login form. (NOT a custom login form) Is this possible? I guess I'm asking if there is a login hook.
-
Building a module - Stuck on getting users
FuturShoc replied to FuturShoc's topic in Module/Plugin Development
Right, ok. -
Building a module - Stuck on getting users
FuturShoc replied to FuturShoc's topic in Module/Plugin Development
Thanks, guys, for your help and taking the time. It is very much appreciated. Here's what I've learned: 1. kongondo, you were right, of course, about my module's class name and the method names inside of it. I revised my method name to "notifyNow()" instead and the associated hook and those errors cleared up. 2. As a result, it seems, my wire('users')->find() call seems to now be working as I felt it should all along. My theory is that the errors with the class/method naming was preventing ProcessWire from doing the necessary bootstrapping to make that call work. Doe that sound right? 3. My goal is to notify users via email. I'm just using $this->message( ) to do interim debugging. Thank you all again! -
Building a module - Stuck on getting users
FuturShoc replied to FuturShoc's topic in Module/Plugin Development
I get the same sort of error when I revise the user code to this. My "superuser" role is ID 38. $us = wire('users')->find("roles=38, include=all"); echo count($us);//returns 2 foreach ($us as $u) { echo $u->name . '<br>'; } -
Building a module - Stuck on getting users
FuturShoc replied to FuturShoc's topic in Module/Plugin Development
Here is my full code at the moment and the error I'm getting: <?php /** * ProcessWire 'Hello world' demonstration module * * Demonstrates the Module interface and how to add hooks. * * See README file for further links regarding module development. * * ProcessWire 2.x * Copyright (C) 2014 by Ryan Cramer * Licensed under GNU/GPL v2, see LICENSE.TXT * * http://processwire.com * */ class Notifybyrole extends WireData implements Module { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( // The module'ss title, typically a little more descriptive than the class name 'title' => 'Notify by role', // version number 'version' => 1, // summary is brief description of what this module is 'summary' => 'Notify site members whose role is ???', // Optional URL to more information about the module 'href' => 'http://inthooz.com', // singular=true: indicates that only one instance of the module is allowed. // This is usually what you want for modules that attach hooks. 'singular' => true, // autoload=true: indicates the module should be started with ProcessWire. // This is necessary for any modules that attach runtime hooks, otherwise those // hooks won't get attached unless some other code calls the module on it's own. // Note that autoload modules are almost always also 'singular' (seen above). 'autoload' => true, // Optional font-awesome icon name, minus the 'fa-' part 'icon' => 'smile-o', ); } /** * Initialize the module * * ProcessWire calls this when the module is loaded. For 'autoload' modules, this will be called * when ProcessWire's API is ready. As a result, this is a good place to attach hooks. * */ public function init() { $this->pages->addHookAfter('save', $this, 'notifyByRole'); } /** * Example1 hooks into the pages->save method and displays a notice every time a page is saved * */ public function notifyByRole($event) { $page = $event->arguments[0]; $us = wire('users')->find('roles=superuser'); echo count($us);//returns 2 foreach ($us as $u) { echo $u->name . '<br>'; } $this->message("Hello World! You saved {$page->path}, {$page->parent->path}."); } } -
Building a module - Stuck on getting users
FuturShoc replied to FuturShoc's topic in Module/Plugin Development
Yes, enabling debugging has improved the feedback I'm getting, yes. Thanks for that reminder. So, I think I understand the issue with my original attempt. However, I don't understand where to go from here to get data back from ProcessWire as I could easily do inside a template via the API. How must the module context be different in order to get the same sort of results? -
HI, guys. Could use some help. I've got the basic module working from the HelloWorld example. My goal is to notify all users of a specific role when a specific subset of pages is updated. So, I'm using the SAVE hook. That's firing just fine on save, but I'm having trouble getting all users of a specific role after that. This works fine, but, of course, gives me a lot of other data I don't need. wire('users') When I try to do this: wire('users')->find("roles=rfp-user") ... my install throws an Internal Server error and breaks the module. What am I doing wrong?
-
AHA. I see your point now. My misunderstanding of PW's URL segments seems to stem from my experiences with CodeIgniter in which URL segments are used in the way I was trying to use them here. My apologies for misunderstanding. Now that I know, it certainly explains why they didn't "work" in my mind. lol Thanks to everyone for their patience and persistence.
-
I don't care about the page name specifically. This was only an example. I want the SECOND URL segment. Specifically, this case: http://tjmahaffey.com/blog/categories/user-experience/ I need to know specifically what the second URL contains so that I can display something different when URL segment #2 is "categories". Page name serves no purpose for me here. I don't care what the page name is. This should not output an empty string. But it does. echo '<pre>'; var_dump($input->urlSegment(2)); echo '</pre>'; Yes.
-
What I'm trying to do is access the SECOND URL segment of a given page in order to change my output in a particular way. Example page: http://tjmahaffey.com/blog/cron-legacy-scheduling-a-mysql-query/ This is in the template: echo '<pre>'; var_dump($input->urlSegment(2)); echo '</pre>'; Shouldn't I be getting this as the var_dump output? string(0) "cron-legacy-scheduling-a-mysql-query"
-
To start, I'm just doing this in my template to make sure its working: Page is: http://tjmahaffey.com/blog/ <?php echo '<pre>'; var_dump($input->urlSegment(1)); echo '</pre>'; ?>
-
I've never been able to get PW's url segment syntax to work. And, yes, I have enabled them in my templates. AND I've added this to my config file: $config->maxUrlSegments = 4; Is there something else I'm missing?
-
Search pages for value contained in a pages field?
FuturShoc replied to FuturShoc's topic in General Support
Thank you for your help! -
I've created a template for physicians. The template has several fields: title body specialty (Page Field) associated_clinics (Page Field) I need to build a search query against the physicians pages, using their specialty and associated_clinics values. But I can't seem to figure out how to write a selector for this purpose. Can anyone lend some insight?
-
I consider that a small price to pay! Thanks again, kongondo.