Leaderboard
Popular Content
Showing content with the highest reputation on 05/28/2018 in all areas
-
It's very, very bad practice to use sleep() in a server side script, that is why documentation on working around the pecularities of PHP's buffering (and thread execution) is so sparse. sleep() blocks the whole thread it is called in, and under heavier load, it makes servers utterly unresponsive. There also fine differences in buffering behaviour depending on how PHP is executed (mod_php, FastCGI, classic CGI...) The usual solution to situations where you are tempted to call sleep() is to poll until the condition you need to wait for has been reached, either using classic reloads for the current page or with AJAX. Nowadays, websockets are also used to split off parts of the work to different processes and notify the "owning" session of changes of state in the backend.4 points
-
A Pageimage instance knows the page it belongs to. See the bottom of the Pagefile documentation (section "Other") for reference. foreach($random_thumbs as $r) { echo "<img src='{$r->url}'> <p>{$r->page->title}</p>"; }3 points
-
This has been tested and here are the results: (1) You cannot install this module from the modules directory – the directory needs to be updated to use the primary module class name, which is GeneralSettings, that would presumably fix the issue, because it would download the whole package, and then install the accompanying Process module, after installing the primary non-process module. (2) there was an error in the main module, in that it was set to autoload false; it needs to autoload in order for the init() function to load on the module config screen, and consequently load the required JS and CSS. (3) There was a return statement executing if there was no saved module config data; this would cause the module to appear to not work, as the required JS would never load (it would have worked if you saved the module once). The asset loading was moved above the possibility of return statement executing so the JS will always load. (4) The only tested admin theme that appears to work is Reno; else things look off... will have to be fixed and tested on the other 2 admin themes. Since I do not have access to edit the module, i edited my repo and then I submitted a pull request to @flydev Once he accepts the changes and the modules repository updates, the module should be in a working state. Note that the reason you want to have a separate process module for your settings is so that you can allow access to the settings screen to non-Superusers. The old module version is going to be a problem for a lot of setups where you expect to provide settings to your other admins.3 points
-
Yeah check your PHP settings, maybe your have output_buffering = Off in place. Did you tried my second example ?1 point
-
Try like that : <?php sleep(3); // sleep 3 seconds echo "wake up<br>"; if (ob_get_length()) { ob_end_flush(); flush(); } sleep(3); echo "hello world<br>"; if (ob_get_length()) { ob_end_flush(); flush(); } sleep(3); or with implicit flush : $hello = ['I', 'love', 'ProcessWire', 'the end']; ob_implicit_flush(true); ob_end_flush(); for($i = 0; $i < count($hello); $i++) { echo $hello[$i].'<br>'; sleep(1); }1 point
-
just added the possibility to add custom sql statements easily. that way you can easily do "reverse queries", for example show all projects that have the current page selected in a page-reference-field: Aggregations like sum(), min(), max() should also be easily possible like this, though they might not be as efficient as doing a group_by manually on the resulting sql.1 point
-
Hi @Karl_T. The module has no ability to modify the session data. It only can modify PW pages. AFAIK session data is not stored as pages. What you can do is add a custom GraphQL mutation field for modifying your session. But that would require you to learn GraphQL and the PHP library that we use. Here is how it might look like <?php namespace ProcessWire; use Youshido\GraphQL\Type\Scalar\BooleanType; use Youshido\GraphQL\Type\Scalar\StringType; use Youshido\GraphQL\Type\Scalar\IntType; use Youshido\GraphQL\Execution\ResolveInfo; $processGraphQL = $modules->get('ProcessGraphQL'); wire()->addHookAfter('ProcessGraphQL::getMutation', function ($event) { $mutation = $event->return; $mutation->addField('modifySessionData', [ 'type' => new BooleanType(), 'args' => [ 'foo' => new StringType(), 'bar' => new IntType(), ], 'resolve' => function ($value, array $args, ResolveInfo $info) { $success = false; // modify session data here... if ($something) { $success = true; } return $success; } ]); }); echo $processGraphQL->executeGraphQL(); And then the query for this could look like this mutation { modifySessionData("foo": "boblibob", "bar": 12234) } Haven't tried it. So there might be something I'm missing. But I hope this gives you the idea of how you can achieve what you want.1 point
-
We have a customer using Sendy for about 6 months now, no problems, about 100k+ newsletters sent. Agree with @Sergio, keep an eye on SES dashboard as it's feedback is not visible in Sendy. We integrated it with Processwire, in as much as we built simple pages(form) where end user adds images and text for a newsletter. This then gets sent to Sendy as HTML Email and a Campaign all ready to go. The concept was to simplify and shield user from complexities of making HTML EMails. We used the Zurb Foundation as the base templates for the HTML EMail code. With Processwire we then merge template and end user form input and send to Sendy via it's API. The calculator on the Sendy.co web site is correct. The AWS SES cost to date for the 100k+ mails is about $USD 10. The clients savings from previous provider for same qty of mailings is approx. $USD 1,000. For a small business this really is significant. Actually, to any business. However, companies like Mailchimp and others are providing a good service, pre built templates, email designs, wizards, security etc... which you are going to have to do yourself to some extent if you go the Sendy route.1 point
-
Today is the last day of school before summer break for my kids—school is getting out early, so I'll keep this post short. But like most weeks, we've got a new core version on the dev branch this week. Core version 3.0.104 contains 13 new commits relative to last week's version, mostly related to resolving minor issues in our GitHub queue. There's not enough interesting material for me to take up your time reading a blog post, so I will save that for next week. But if you are running on the dev branch then it's definitely worth grabbing. If you are using AdminThemeUikit, this version has several minor tweaks and improvements to that admin theme as well. Plenty more to come next week. Thanks for reading, and have a great weekend!1 point
-
I've been working with FieldtypeOptions recently and in the absence of documentation thought I would share some example code: $field = $fields->get('test_options'); /* @var FieldtypeOptions $fieldtype */ $fieldtype = $field->type; // Get existing options // $options is a SelectableOptionsArray (WireArray) // If there are no options yet this will return an empty SelectableOptionsArray $options = $fieldtype->getOptions($field); // Create an option $yellow = new SelectableOption(); $yellow->title = 'Yellow'; $yellow->value = 'yel'; // if you want a different value from the title // Don't set an ID for new options - this is added automatically // Will deal with 'sort' property later // Create another option $orange = new SelectableOption(); $orange->title = 'Orange'; // Add option after the existing options $options->add($yellow); // Get an option by title $green = $options->get('title=Green'); // Insert option at a certain position $options->insertAfter($orange, $green); // Remove an option $options->remove($green); // Reset sort properties (so order of options is the same as the SelectableOptionsArray order) $sort = 0; foreach($options as $option) { $option->sort = $sort; $sort++; } // Set options back to field $fieldtype->setOptions($field, $options);1 point
-
Hi @titanium, You might want to consider doing it in a different way, by creating field+pages for such settings, for example like this: http://processwire-recipes.com/recipes/create-custom-admin-settings-page-link-in-admin-menu/ Quite a different approach for sure but it might work for you.1 point
-
Ah, here is a very valuable post from within the case studio of the National Geographic Site: https://processwire.com/talk/topic/7494-case-study-the-triumph-of-national-geographic-traveller-india-in-processwire/page-2#entry72498 And, also it is that mainly new users ask here the community, I want ask one question too: What are the alternatives to PW?1 point
-
@Pete - i'm wondering how to 'addon' to this module in the sense that your module provides a blank canvas for setting up a dashboard, but i'd like to avoid changing anything in your module and also avoid putting anything custom into the module folder; what i did to hack this was change the dashboard module like this: public function execute() { // Redirect calls for the admin homepage to the dashboard (first child page) if ($this->page->id == 2) { $this->session->redirect($this->page->child->url); } $dashboard = $this->getDashboard(); return $dashboard->render(); } public function ___getDashboard() { $t = new TemplateFile($this->config->paths->siteModules . __CLASS__ . "/dashboard.php"); return $t; } then in my dashboard widgets module, i have this: public function init() { $this->addHookAfter('ProcessDashboard::getDashboard', $this, 'getCustomDashboard'); } public function getCustomDashboard(HookEvent $event) { $template = $event->return; $event->replace = true; $template = new TemplateFile($this->config->paths->siteModules . __CLASS__ . "/dashboard.php"); $event->return = $template; } let me know what you think, if this would be a possible change that wouldn't affect existing sites, but would allow other modules to hook into the main dashboard for rendering...1 point