-
Posts
82 -
Joined
-
Last visited
Everything posted by FuturShoc
-
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.
-
Fantastic work, kongondo. Your module is much needed for those of us who don't want to spend a lot of time stripping out the markup on Ryan's (equally awesome) blog module. One question: I notice that blog posts have this url: www.domain/blog/posts/my-post-here Have you considered any approach which might remove "/posts/" from that URL? My existing blog doesn't have the extra segment and I'd love to keep it that way, if possible. I've also been thinking I could remove it via htaccess.
-
Thanks, adrian. Unfortunately, moving them to /sites/ didn't change my issue. Yes, I agree that moving the files into the CMS itself would be best, but I was looking for a quick fix. Looks like I'll have to go that route!
-
Here's my dev site. http://ahaa.inthooz.me/state-forms/ I've used a standard body field for this page's template and added a list to the page. Each list item has a link to a file download. Those files are just uploaded to a subfolder of the site root. The links to those files (.doc and .docx) ARE valid, but clicking those links throws a 404 from PW. Can anyone tell me why or how to fix this? I don't remember this ever being an issue before.
-
Display issue with CKEditor module - Refresh req?
FuturShoc replied to FuturShoc's topic in Modules/Plugins
arjen, thanks for the thread referral. I'll try a few of these fixes and see which works best for me. -
Display issue with CKEditor module - Refresh req?
FuturShoc replied to FuturShoc's topic in Modules/Plugins
Anyone have any ideas? -
Just installed CK editor on some of the fields on a PW install. ProcessWire 2.3 It appears that most often when editing a page that uses a CKEditor field, the field contents aren't shown until I refresh the page. JS console shows this error on initial load when the content isn't showing initially: 'undefined' is not an object (evaluating 'b.body') Can anyone offer insight or a fix?
-
I've installed the module and followed the most up to date instructions and I'm using PW 2.3.0. My new admin page's name does appear at the top of my PW admin area: "Pages", "Setup", "Modules", "Access", "myadminpage". BUT, when I click on myadminpage, I get a 500 server error. Is there something else I need to check?
-
Thanks for the clarification, teppo. That goes a long way toward my understanding the boundaries of bootstrap'ing PM. I knew it had to be some gap in my understanding, not an issue with PM itself.
-
Thank you, titanium. That seems to have done the trick for me, though this call gives me an internal server error: wire('sanitizer')->email($email); I had been referring to the API docs, but for some reason hadn't been using that syntax because it worked as-is on my site's home page... I wonder why it didn't require the wire() syntax...
-
I've been using this same code on my site's homepage form without a problem. However, I'm moving it to a stand-alone script called by the same form which is now on an interior page of the site. The script below is a plain PHP file that lives in a subfolder of the root directory. I'm getting no errors including the PW index file, per bootstrapping, but my api calls don't seem to be working... Can anyone help? <?php $email = $_POST['email']; $password = $_POST['password']; include("../../index.php"); if($email && $password) { if ($email == 'visitor') { $emailUser = $users->get("name=visitor"); } else { $email = $sanitizer->email($email); $emailUser = $users->get("email=$email"); } if($emailUser->id) { $user = $session->login($emailUser->name, $password); if($user) { $session->redirect('/catalog'); //echo 'logged in'; } else { echo "Login failed!"; } } else { echo "Unrecognized email address"; } } ?>