Leaderboard
Popular Content
Showing content with the highest reputation on 05/29/2018 in all areas
-
I'm so glad I wanted to share that with you today. Since November 2017, all of the company's infrastructure is built on ProcessWire. Whether it is the showcase website or the millions of transactions recorded in the database as pages or all the custom modules to interact with the company's data. Just to say that I feel lucky to work all the day with what I love, and when I remember that I was demoralized thinking I had to learn Wordpress or I don't know what, because before ProcessWire I never worked with a CMS and it was becoming vital. Then I stumbled on ProcessWire (hooray!). And now, a new step for me appeared yesterday. I have a trainee for a month. And my task is to teach him how to work with ProcessWire! This make me really proud ! Have a nice day everyone and again, thanks to this community and this software! ?30 points
-
Yes I should take the time to write a showcase, I am sure that our use of ProcessWire will interest a lot of people!13 points
-
I'd like a lot to have a teacher ?, learning alone sometimes it is very stressful!! Anyway, I take this opportunity to say really thank all of you members of the forum that you helped me so much! specially you @flydev that help me a lot with the login/registration module!! surely you will be a good teacher!4 points
-
Try this hook in hook $this->addHookBefore('PageRender::renderPage', function($e) { $event = $e->arguments[0]; $page = $event->object; $user = $this->wire('user'); // QUICK EXIT if ($user->isSuperuser()) return; // superuser if (!empty($page->template) && $page->template->id == 2) return; // backend if ($user->language->isDefault()) return; // default language $language = $user->language; $currentLanguageStatus = $page->get("status$language"); if ($currentLanguageStatus == 0) { $otherPage = $this->wire('pages')->get(1234); // get page to be rendered instead $event = new HookEvent(array('object' => $otherPage)); $e->arguments(0, $event); } });3 points
-
You can change the module service url in your config.php file. $config->moduleServiceURL = 'http://modules.processwire.com/export-json/'; $config->moduleServiceKey = (__NAMESPACE__ ? 'pw300' : 'pw280'); Format of the complete url: {moduleServiceURL}/{moduleClassName}/?apikey={moduleServiceKey} Example: http://modules.processwire.com/export-json/MarkupCookieConsent/?apikey=pw300 If you provide this service (json format) for your module by your own you could hook in ProcessModule::execute if ($input->get->update) { $this->addHookBefore('ProcessModule::execute', function($e) { $moduleClassName = $this->wire('sanitizer')->name($this->wire('input')->get->update); if ($moduleClassName != 'MySuperPrivateModule') return; // change service url here $this->wire('config')->moduleServiceURL = 'http://example.com/export-json/'; }); } Another solution: Symlink your module if all sites using this module are hosted on the same server.2 points
-
Hi flydev, That's actually a great achievement to get processwire applied on a company scale, congratulations. I would feel proud too !2 points
-
All forms in the backend of processwire are secured against CSRF attacks by assigning them a one-time token. This will ensure that the page and the current session that generates the form is the same as the one that receives the form. E. g. The error message appears when a backend page (also Login) is open and the session has expired, or the session cookie has been deleted from the browser or could not be set in the browser.2 points
-
Yep, as @Autofahrn said it's easy to do that via the API and a foreach. But I would suggest using Tracy Console instead of a template. Just create your code, debug it instantly using d() and CTRL/ALT+Enter and then finally do the import when everything works as expected. You can use the Password class to generate new passwords: $pw = new Password(); $pw = $pw->randomPass([ 'minLength' => 10, 'maxLength' => 10, 'maxSymbols' => -1, 'minUpper' => 0, 'maxUpper' => -1, ]); See https://github.com/processwire/processwire/blob/master/wire/core/Password.php#L4191 point
-
If you can export the user as JSON, it should be simple enough to write a small importer in PHP. When I did similar, I created a template with a simple file field holding the JSON containing the user database. The associated template php starts like this: <?php namespace ProcessWire; if(isset($page->json_file)) $UserData = json_decode(file_get_contents($page->json_file->path . $page->json_file->first()->name), true); else $UserData = [ ]; // ensure always set, yet empty. depending on your JSON structure you'll iterate through your users somewhat like this: foreach($UserData as $v) { // Fetch whatever fields should be imported $UserLoginName = $v["LoginName"]; $UserRealName = $v["RealName"]; $UserMail = $v["EMail"]; In my implementation I'm building a pagename from the original name and check if the user actually exists: $UserPwName = $sanitizer->pageName($UserLoginName, true); $usr = $users->get("name={$UserPwName}"); Of course you only want to add a user which does not exist yet (you may do other things like update for existing users): if($usr->id == 0) // User does not exist { $usr = $users->add($UserPwName); // Create user if($usr->id) // Success? { $usr->of(false); // Prepare for update $usr->email = $UserMail; $usr->addRole('imported-user'); // add some special role here // add more fields depending on your use case // $usr->user_name = $UserRealName; $usr->save(); } else { // may $log->error("ERROR creating user {$UserRealName}"); } } Shouldn't be too difficult to adapt for other scenarios. Take care of the passwords, which likely can't be migrated that way!1 point
-
Congratulation @flydev !! You are an amazing contributor to this community and it shows in how you influence businesses decisions with your work and dedication and that's invaluable for all of us looking to get jobs using PW.1 point
-
@Jon this sounds a little strange. Reading most of your comment, I would think that this might have something to do with your Office365 having sending limits that you're going over. The TLS issue is what makes it weird, though - because if it was a limits problem, that would not be happening. Is there anything in the logs that gives what error is encountered, rather than saying it just stops sending?1 point
-
Bravo ? !! I'm thinking about using ProcessWire as a foundation for a marketplace. Glad to see ProcessWire works very well for you. Without selling your company's trade secret it would be great to get some insights about how you use ProcessWire.1 point
-
Thank you @pwired, I try to use this module, I have made the Json file try to upload but give me this error, Anyway I don't think can work. because this module don't ask me where I want store the data. -------- I think something like the modulo http://modules.processwire.com/modules/import-pages-xml/ of @justb3a could work. The only problem it's this fill the template, and the registration filed aren't in a template but inside a module. I can not connect the xml file to the field for let go the info in the right database tables.1 point
-
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>"; }1 point
-
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.1 point
-
You may need a hook to get it done, take a look on this thread: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
-
@tires The pull request is here https://github.com/ryancramerdesign/TextformatterVideoEmbed/pull/121 point
-
Default session lifetime is 86400 seconds. You can change this to any value you want. // config.php $config->sessionExpireSeconds = 86400; Allow/ disallow sessions (and the wire cookie) under conditions. Remind that you need this to have access to the backend admin. // config.php $config->sessionAllow = true; If you want to disable cookies only for the frontend /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // otherwise disallow session return false; }; If you want to use cookies respecting EU Cookie law I recommend Cans Module MarkupCookieConsent in combination with this settings. /** * config.php * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // user accepted cookies due to EU law (Module MarkupCookieConsent) if(!empty($_COOKIE['eu-cookie'])) return true; // otherwise disallow session return false; }; Use the core module SessionHandlerDB to store session vars in the database. Learn more about session setting options and sessions by reading the comments in the files /wire/config.php or /wire/core/Session.php of your processwire installation.1 point