Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/10/2017 in all areas

  1. Greetings. I am here to share my first module. I make this module because I cannot find one to suit my need. I like SessionHandlerDB but I do not want to use mysql database to store session for performance. So, Redis seems to be the best choice. I have tried to use netcarver's SessionHandlerRedis but it lacks something I need, those are the active session checking and the easy module configuration while I do borrow some code from it (thanks to netcarver). So I take this chance to merge them together to form a new module. I am new to use github and I don't know if it is appropriate to publish another similar project, or fork from them. You may grab this from Github: SessionHandlerDBRedis I hope this could give somebody a help. Updated to v0.4 changelog: v0.3 - added ability to get forwarded IP instead of normal remote IP. v0.4 - added session lock
    2 points
  2. Your function takes an argument but your hook is not passing one?
    2 points
  3. Block the ip in your firewall and see where the error does come up. Also editing the .htaccess won't help anything because it's used for incoming request not outgoing ones. You could try to log WireHttp usage, which I think is used by core modules with outgoing requests.
    2 points
  4. You don't even need to set the return value to it's previous value. Just don't modify it if you don't need to: function pageRenderHookMethod (HookEvent $event) { if ('my condition' != true) return; $event->return = 'my custom return value'; } But most often it's the better solution to use a before hook and prevent the original render function from running uselessly if it's return value might be replaced anyways: function pageBeforeRenderHookMethod (HookEvent $event) { if ('my condition' != true) return; // Let the original $page->render() do it's job $event->replace = true; // Skip the original $page->render() $event->return = 'custom value'; }
    2 points
  5. Hi and welcome @ren! I recommend you install the Tracy Debugger module as you'll find this an essential tool when developing. Then you can dump the $page object above your if() conditional and explore what its properties are (parent, url, etc). It should be obvious then why $page will or will not match those conditions you have set. // do not redirect if page matches: bd($this->page, 'page'); if($this->page->template != "admin" // any non-admin page || $this->page->is($this->redirectPage) // the dashboard page (prevent infinite loop) || $this->page->parent->is('/admin/login/') // various attempts to allow logging out || $this->wire("process") == 'ProcessLogin' || strpos($this->page->url, $this->wire('config')->urls->admin . 'login/logout') !== false ) { return; }
    2 points
  6. Hi @bmacnaughton You can add a custom field to language template and put needed values there. Just choose "Show system fields" in the template manager.
    2 points
  7. I added support for FieldtypeMapMarker (->location) if you want to incorporate into the module master, here
    1 point
  8. Not sure but perhaps because you are not checking the process property of $this->page, i.e. instead of this... || $this->wire("process") == 'ProcessLogin' ...try... || $this->page->process == 'ProcessLogin'
    1 point
  9. Hi @Robin S, Thanks, Tracy Debugger is looovely. I did as you said, and put db calls to log both cases (redirect and no redirect): // do not redirect if page matches: if($this->page->template != "admin" // any non-admin page || $this->page->is($this->redirectPage) // the dashboard page (prevent infinite loop) || $this->page->parent->is('/admin/login/') // various attempts to allow logging out || $this->wire("process") == 'ProcessLogin' || strpos($this->page->url, $this->wire('config')->urls->admin . 'login/logout') !== false ) { bd($this->page, 'no redirect page'); return; } bd($this->page, 'redirect page'); When I tried to logout it logged both cases, with 'redirect page' first: data protected => array (3) title => "Login" (5) process => "ProcessLogin" (12) urlSegment => "logout" (6) ... for some reason 'ProcessLogin' is sailing through the conditional. Followed by 'no redirect page': data protected => array (2) title => "Dashboard" (9) process => "ProcessDashboard" (16) The first log gave me the idea to match the urlSegment, which works a charm! So if it's of any use to anyone, the working code is: if($this->page->template != "admin" || $this->page->is($this->redirectPage) || $this->input->urlSegment1 == 'logout') { return; } // find roles set in module configuration and create array $roles = explode(',', $this->userRoles); // for each user in module config check to see if current user foreach ($roles as $key => $val) { // get a role from the roles array $roles[$key] = trim($roles[$key]); // if current user found with role then redirect if($this->user->hasRole($roles[$key])){ // redirect session to page stored in config $this->session->redirect($this->redirectPage); // code should never get here but this is a simple fallback break; } } Thanks Robin, you've been a great help, and I'm sure to be using Tracy Debugger again
    1 point
  10. There is limited (and undocumented) AJAX 'dependent selects' support built into Page Reference fields. You must use the 'Custom find' or 'Selector string' option for defining selectable pages, and reference the source Page Reference field (that exists on the same page) using syntax like this: parent=page.page_reference_field_name Based on testing I have found: It only works for Select, Select Multiple or AsmSelect inputfields It does not work inside a repeater item
    1 point
  11. When looping over the pages in a Page field, set some property to the Page object to serve as an indicator that the page has been processed. Then put your code that processes the pages inside an if() condition that checks that the property has not already been set. So something like: if(!$page->processed) { // do your processing here // ... $page->processed = true; }
    1 point
  12. @Pretobrazza trying to answer your questions: 1. As stated in the MarkupLeaflet.module file, you are required to add the link to leaflet.js yourself. You can change the version to 1.0.3. Then you also have to change the link to the leaflet css in the same file line 106. If you decide to use the getLeafletMapHeaderLines method for injecting JS and CSS then you need to change lines 168 and 173. 2. This module does not support wms layers out of the box. You would need to expand the JS logic to use them. Over at leafletjs.com they have a tutorial on how to implement wms layers. The relevant code section in the module can be found in MarkupLeafletMap.js line 47. Following the tutorial on leaflet.js you might have to alter some other code in that file, too. 3. There is a shapefile plugin for leaflet.js that you could use to draw layers from your shape file. You can use the PW API and some PHP logic to create that shape file from the data in your pages, but I'm afraid this goes beyond the scope of this thread. This module is designed to draw markers of locations on a map where you can choose different map tile providers and assign custom fontawesome icons to your markers. All in all I think ProcessWire fits the job very well. But you might be better off just using the inputfield from this module on your pages to input the location data. And then setup the map rendering from scratch in your template file rather then using the render method that MarkupLeaflet.module provides. This should be easier than tweaking the render logic that this module provides. I can definitly encourage you trying to do this with PW and leaflet.js.
    1 point
  13. Hey! My pull request with an integration for PW for the Toggl Chrome button was just accepted, yay! https://github.com/toggl/toggl-button/pull/788 For those who don't know, Toggl is a really great time tracker, and they have a handy Chrome extension that integrates with web apps by adding Toggl buttons to tasks and projects. Generally, these integrations are with task manager apps and CRMs, but I thought I could develop an integration for the PW admin. Although I did it mostly for the fun of it, I think this can be useful in some cases, and definitely it's great to see PW featured on their extension and github page!. They also seem to be quite picky with these integrations, so I'm glad they accepted the pull request. Here are some images to give you a taste of it
    1 point
  14. // save user default language $savedLanguage = wire("user")->language; $emailLangauge = wire("languages")->get("german"); wire("user")->language = $emailLangauge; $mail = $yourpage->render(); // restore the original language setting wire("user")->language = $savedLanguage; Not tested
    1 point
  15. You need to manually install pim2 under site/modules/, and UN-install pim. Than you can use pim2load. You can read about it in the very first post of this thread: https://processwire.com/talk/topic/4264-page-image-manipulator-1/ right at the top of that post.
    1 point
  16. function pageRenderHookMethod (HookEvent $event) { $default = $event->return; if ('my condition' == true) { $event->return = 'my custom return value'; } else { $event->return = $default; } } If you hook after you don't need $event->replace = true;
    1 point
  17. For a project I've posted yesterday I built a basic module to subscribe users to a Sendy installation. I love Sendy and my client too as we use it to send lots of emails using Amazon SES costing almost nothing at all. Do guys think that's worth to post about? It's very basic now, it doesn't use Sendy's API at all, it just send the data using POST to subscribe the users to different lists.
    1 point
  18. Accessing anything inside the admin backend does require the page-edit permission, which you surely wouldn't want to give to your guest user role. I'm also not sure why you created a Process module to render an ajax response. Process modules are to render admin backend pages, e.g. to be used in the backend. For your usecase I'd rather rather use a plain pw module with some public method to generate your ajax response. Then you can create the ajax endpoint as a simple template/page in your page tree. The template file can then just call your module's method and return it. This way you can control your ajax endpoint like any other page, while still having the logic to generate your markup in the module.
    1 point
  19. For any Windows developers interested in an easy way to get going with Docker and Processwire that includes local debugging... https://github.com/rastographics/pwocker Local debugging in your IDE with Xdebug pre-configured. (Also includes working launch.json for you VS Code users ) Use *.localtest.me hostnames for each site you are developing (no editing of hosts file) Simple configuration...copy 2 files into your project, edit a couple variables in those files, and run 1 command per project. Tested with Docker 1.13.1-beta42 on Windows 10 Pro 64-bit. I didn't know much at all about Docker, nginx, or xdebug before doing this, so I pulled much info from gebeer's work and many others who have put Docker/PHP/xdebug stuff out in the community. And it may not be the best setup ever, but it finally gives me what I needed for doing PW work on Windows in a true Linux stack with IDE debugging.
    1 point
  20. OK BIG thanks to soma, who helped me get this, here is the final one: <?php $limit = 5; // the "limit"-setting used on this page $children = $page->children("limit=" . $limit); $totalpages = ceil($children->getTotal() / $limit); // PAGINATOR: set SEO tags for Google if ($input->pageNum) { if ($input->pageNum < $totalpages) { echo "<a rel='next' href='" . $page->url . $config->pageNumUrlPrefix . ($input->pageNum + 1) . "'>Next "; } else { echo "Thanks for browsing, you have reached the bottom of this page!"; } } ?> Once again, thanks to all for thinking along, now the next hurdle, to get infinitescroll to do the rest!
    1 point
  21. This is really interesting stuff and I'm learning so much from it. I've already tested Soma's code and it works very well. Is there a way of configuring $form->render() so that it outputs different html (divs for ul/li etc.)?
    1 point
  22. Apeisa is right. But if you really can't help it and it is a must you can do this: $pages->get("/path/, include=all");
    1 point
×
×
  • Create New...