-
Posts
636 -
Joined
-
Last visited
-
Days Won
8
Everything posted by psy
-
@teppo Thanks for the tip. Was a bit confused about naming conventions. The module doesn't render anything so not Markup, and to me, it was a 'process', although granted, not a PW process. Done. Let me know if there are any problems relating to the name change.
-
ProcessWire DropboxAPI on GitHub: https://github.com/clipmagic/DropboxAPI This module is a wrapper for Kunal Varma's Dropbox PHP SDK https://github.com/kunalvarma05/dropbox-php-sdk It was created to perform a specific function for a client, ie upload PDF files on a PW website to a specific Dropbox account folder. The PDF files, created using @Wanze's excellent PagesToPdf module using the WirePDF functions, are generated from Formbuilder forms completed by front-end site visitors. Works a treat! There's more that could be done to allow ProcessWire to take advantage of all the features of the SDK, eg downloads, multiple Dropbox accounts, etc. You are welcome to request changes and/or fork the GitHub project to extend the feature set. Enjoy! System requirements PHP 5.6.4 or greater Composer The PHP mbstring extension General information This module enables you to access a single Dropbox (www.dropbox.com) account to upload files from a ProcessWire website. All kudos to (https://github.com/kunalvarma05/dropbox-php-sdk) for the PHP API. First steps Visit (https://www.dropbox.com/developers) and read the documentation. Log into Dropbox and create a new application. It's recommended to limit ProcessWire App access to a specified folder Make a note of the App key, the App secret and the name of the Dropbox folder Installation Download the zip file into your site/modules folder then expand the zip file. Next, login to ProcessWire > go to Modules > click "Refresh". You should see a note that a new module was found. Install the DropboxAPI module. Configure the module with your App key, App secret and your Call Back URL You need to generate a Dropbox access token to enable your site to communicate with the nominated Dropbox account. Dropbox will generate a token for you or you can create a page for the front end of your ProcessWire site with a template to submit the token request to Dropbox, eg: <?php namespace ProcessWire; $drop = $modules->get('DropboxAPI'); if ($input->get->code && $input->get->state) { $code = $sanitizer->text($input->get->code); $state = $sanitizer->text($input->get->state); //Fetch the AccessToken $accessToken = $drop->getAccessToken($code, $state); echo "Copy/paste this code into the module configuration: " . $accessToken; } else { echo "<p><a href='" . $drop->getAuthURL() . "'>Log in with Dropbox</a></p>"; } ?> Once you have entered the token in the module configuration, you can unpublish this page. Usage Read the dropbox-php-sdk documentation! An example template for sending a file to a Dropbox App folder from ProcessWire: <?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; // send pdf to Dropbox $drop = $modules->get('DropboxAPI'); $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); if ($app) { //Configure Dropbox service $dropbox = new Dropbox($app); $dropboxFile = new DropboxFile('/path/to/myfilename.pdf'); $file = $dropbox->upload($dropboxFile, "/myfilename.pdf", ['autorename' => true]); //Uploaded File meta data if ($file) { $success = $file->getName() . " uploaded to Dropbox"; $drop->log($success); } }
- 38 replies
-
- 13
-
Hi @maxf5 Thanks for the feedback. Wow, what results. Definitely not getting those slow speeds here. Will work on reducing the images sizes.
-
Feeling the love for ProcessWire today. Two sites launched and owners over the moon happy. Two additional sites ordered by existing clients and both specified ProcessWire as the platform. New sites: 1. https://flywithmehorses.com.au/ Owner is just starting out in business and had already spent $100's dollars and 6+ months on a 'free' website without success. She helped me so I sponsored development of her site. Client's comment: "OMGOSH this is sooo exciting!!!!!!! YAY!! Thank you alot!!!!! Can't wait to tell everyone!!! THANK YOU!!!" ProcessWire 3.0.63 2. https://cttcfilmcourse.com/ Original site built in WordPress. Over 1000 lines of code on the home page and the https://validator.w3.org/ bombed out at line 124 with "Too many errors". Google's page speed insights were cringingly bad. Project was to keep the visuals and rebuild the site in PW with a solid foundation. Job done. No validation errors and vastly improved page speed insights. Also added search and better site navigation. Client's comment: "So good!" ProcessWire 3.0.63 Looking forward to working on the next two sites, both of which will be website apps with workflows rather than informational sites. As ever, grateful for comments/feedback to improve either site.
- 4 replies
-
- 18
-
Quick workaround... in _main.php add <region id="dummy"></region> in basic-page.php add <region id="dummy"></region> Seems PW needs a region in the page template to kick-start the process.
-
I am using regions with the tag <region id="whatever"> in the _main.php file. Config file is set up as follows: $config->useMarkupRegions = true; $config->prependTemplateFile = '_init.php'; $config->appendTemplateFile = '_main.php'; When I use a page template that changes a region, all goes well. However, I set up the _main.php file to reflect the output for a basic page. The basic-page.php template needed no customisation so was simply as follows: <?php namespace ProcessWire; ?> When a page with the basic-page template was output, all the <region> tags remained in the HTML, ie were not stripped. When I added a customised region to the basic-page.php template, all the <region> tags were stripped from the output _main.php HTML. Did I do something wrong or is this a bug? Using ProcessWire 3.0.63 © 2017
-
There are many. I trawled the FB forum on the assumption my requirement wasn't unique Here's one:
-
This works for me. User name is generated by PW from first name and last name fields. New user enters email, password and a couple of custom fields. The user must be saved before the roles are added. Hook developed with help, esp from Ryan, in the FormBuilder forum. // Create new user from FormBuilder feu-register form $forms->addHookAfter('InputfieldForm::processInput', null, 'hookCreateUser'); function hookCreateUser(HookEvent $event) { $form = $event->object; if($form->name != 'my-fb-form-name') return; // if it's not the form you want, return // format the first_name and last_name as the username $sanitizer = wire('sanitizer'); $users = wire('users'); // ensure email address is valid and unique $email = $form->get('email'); $emailValue = $sanitizer->selectorValue($email->value); if($emailValue) { // check there aren't any other users with the same email $insiders = $users->find("include=all, email=$emailValue"); if($insiders->count > 0) { $email->error(__("Sorry that email is already in use")); return false; } } // makes sure the username is not already in use. $first_name = $sanitizer->pageName($form->get('first_name')->value); $last_name = $sanitizer->pageName($form->get('last_name')->value); if ($first_name && $last_name ) { $username = $first_name . '_' . $last_name; $u = $users->find("include=all, name^=$username"); if ($u->count > 0) { $number = $u->count+1; $username = $username . $number; } } else { // invalid or blank $username->error(__("Please enter a valid username")); } // ok, all checked, create user account $newUser = $users->add($username); $newUser->of(false); $newUser->email = $emailValue; $newUser->pass = $form->get('password')->value; $newUser->first_name = $form->get('first_name')->value; $newUser->last_name = $form->get('last_name')->value; $newUser->country = $sanitizer->text($form->get('country')->value); $newUser->phone = $sanitizer->text($form->get('phone')->value); $newUser->save(); $newUser->addRole('guest'); $newUser->addRole('my-custom-user-role'); // change to your user role name $newUser->save(); $newUser->of(true); }
-
@Macrura Thanks, sorry for the late reply, just saw your comment. Forgot to add album template to MarkupSEO allowed template list. Fixed
-
Solved!!! Answer was in the .htaccess file. Remove reference to robots.txt being a physical file on the system. #RewriteCond %{REQUEST_FILENAME} !(favicon\.ico|robots\.txt) RewriteCond %{REQUEST_FILENAME} !(favicon\.ico)
-
Same for me Thought maybe it was a $config setting but couldn't find anything. Suggestions?
-
@OllieMackJames Glad you like it There are way too many schemas for me to include in the basic module. I chose what I thought would be the most useful. However you have a couple of options: 1. Use the custom schema option, eg: $jsonld = $modules->get("MarkupJsonLDSchema"); $options = array(); $options["@type"] = "VideoObject"; $options["custom"] = array ( "actor" => "Barney Rubble", "caption" => "What an actor!", ... ); ?> <script type="application/ld+json"> <?php $jsonld->render('Custom',$options); ?> </script> OR 2. Write your own schema and add it to the site/modules/MarkupJsonLDSchema/schemas/ directory. See the other schemas in there and their naming conventions as examples, and feel free to include your video schema code in this topic to share with others. BTW, the link http://jsonld.com/video/ leads to a 404 Error. A much better resource is http://schema.org/VideoObject. Hope this helps psy
-
Strangely, the odd order of the pw-append method was definitely repeatable for me. Even with the scripts in the correct order I was still having issues with js errors. The <region> tag works ONLY if I have ProCache turned on to combine & minify scripts. Guessing the same would apply to All-In-One-Minify or similar modules. At least in my case, inline scripts execute too quickly unless the preceding scripts are forced to be loaded beforehand. Lesson learned and all good
-
Thanks Robin, forgot about the <region> tag. Good call!
-
I've configured my PW site to use regions and mostly it's fabulous. However I encountered a strange problem when appending scripts to the body tag of a template. The body tag id is "bodyTag" (duh!). There are 3 scripts - two external and one inline. My first attempt was to append each script individually thinking they'd appear in the same order on the output: <script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX" pw-append="bodyTag"></script> <script id="localMapsJS" type="text/javascript" src="<?=$bootstrap?>js/jquery.gmap.js" pw-append="bodyTag"></script> <script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script> Not so! Got lots of js errors and discovered the output had placed the scripts in the incorrect order, ie: <script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script> <script id="localMapsJS" type="text/javascript" src="/site/assets/mytheme/js/jquery.gmap.js"></script> <script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX"></script> In other places I've appended multiple HTML regions to the same tag and it's worked fine. It only happens with scripts. After trying a few things, I discovered a workaround which was to wrap all the scripts into one div which is then appended to the body tag. This is OK but not ideal. I think (?), the partial is rendered in its entirety before being appended to the body tag: <div pw-append="bodyTag"> <script id="googlemapskey" type="text/javascript" src="https://maps.google.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXX"></script> <script id="localMapsJS" type="text/javascript" src="<?=$bootstrap?>js/jquery.gmap.js"></script> <script type="text/javascript" pw-append="bodyTag"> jQuery(document).ready(function($){ ... }); </script> </div> Curious to know where I went wrong in the first example with each script appended individually or is this behaviour with scripts an undocumented feature of regions? Using PW 3.0.61 with both Chrome and Firefox
-
Another way perhaps: When you look in the database at field_pagetablefieldname you will see 3 columns - pages_id = the page on which the PageTable appears (this is what you need) data = the id of the PageTable page sort = sort order for the items to appear on the pages_id page You could hook after the new PageTable entry is saved (ie Pages::saved), and do a $database call to select the pages_id that has the newly created page id in the data field.
-
Thanks Juergen and a great suggestion re the anchor. Achieved it with Ryan's snippet: // scroll to form submitted message jQuery(document).ready(function($) { var f = $('#FormBuilderSubmitted'); if(!f.length) return; var y = f.offset().top; $('body').animate( { scrollTop: y }, 'slow'); });
-
This site was one of my first PW attempts a couple of years ago. I recently upgraded it to PW 3.0.60 and changed it to delayed output rather than header/body/footer format. URL: https://rockpoolpainting.com.au/ PW: v3.0.60 Modules: Admin Help Page Admin Help Setup Admin Help Tab Admin Save Actions Database Backups Email Obfuscator File (for FormBuilder) Form Builder Forms Jquery jQuery DataTables Plugin Json-LD Schema Markup Simple Navigation Markup Sitemap XML Mobile Detect Modules Manager Modules Manager Notification Page Delete ProCache ProFields: Table Template Editor Templates Reference (multiple) Features: To keep the home page content fresh, the list of services (repeater field) and 'Examples of our work' (Gallery page children, limit = 3) are randomly shuffled. Display changes subject to ProCache refresh. Testimonials are also randomly shuffled to keep content fresh Submission of the testimonial form adds the form data to an unpublished item in a pagetable on the testimonials admin page so the admin doesn't have to go to Setup->Forms->testimonial->Entries to view/edit/approve/delete the new submission (thanks netcarver ) Framework is Bootstrap although didn't use Bootstrap profile All pages validate on https://validator.w3.org/ Considering the number of images and the fact it's on a shared host, page speeds are acceptable on https://developers.google.com/speed/pagespeed/insights/ Photos of Tuggerah are my kitchen that Chris painted
- 5 replies
-
- 12
-
Had a couple of older PW 2.7 sites slow to the point of failure this week. A bit of digging revealed that the external image compression service used by ProcessImageMinimize is no longer available. Development on the module ceased some time ago. Quick fix was to uninstall the module and edit the output code to use native PW image options. All affected sites operational again. Next step is to update them to PW3.0+ ...
-
This module enables you to automatically create pages based on a ProcessWire page template, eg Calender detail page, that has calendar event recurrences. Download from GitHub: https://github.com/clipmagic/ProcessRecurringEvents
-
Need calendar functionality for a few of my sites and it was doing my head in. After much research, trial and error, decided to go back to the KISS principle (Keep It Simple Sweetie). PW handles dates well so can just be fields in templates Selectors allow you to define start and end end dates easily Want each event page to be a child page of the Calendar page and editable in its own right Only issue was recurring events and this post has given me ideas Am going to adapt Mr NiceGuys code to suit. Happy camper!
-
Thanks netcarver, will try this on a LazyCron hook that doesn't fire as expected. Hook is in API/page template, not module. Have been trying to figure out the problem for ages. It fired once, and once only... LazyCron times are recorded as expected in assets/cache/LazyCron.cache but nothing ever happens.
-
I wanted to view the contents of a JSON post in a web hook from an external application. In this instance the source application was Stripe posting event info at irregular intervals to a PW page URL. The process had to be unobtrusive. Solution was to send an email to myself. The web hook page template contained: // create a PW mail object using whatever method works for you $mail = wire()->modules('WireMailSmtp'); // Retrieve the request's body and parse it as JSON $stripe_input = @file_get_contents("php://input"); $event_json = json_decode($stripe_input); try { $body = "<pre>" . var_export($event_json, true) . "</pre>"; $mail->to('my@emailaddress.com'); $mail->from('from@emailaddress.com'); $mail->subject('test event_json'); $mail->bodyHTML($body); $mail->send(); } catch (\Exception $e) { $error = "Email not sent: " . $e->getMessage(); $mail->log($error); } Resulting email body contains nicely formatted code, eg: stdClass::__set_state(array( 'id' => 'evt_XXXXXXXXXXXXXXXX', 'object' => 'event', 'api_version' => '2016-07-06', 'created' => 1476900798, 'data' => stdClass::__set_state(array( 'object' => stdClass::__set_state(array( 'id' => 'sub_XXXXXXXXXXXXXXXX', 'object' => 'subscription', 'application_fee_percent' => NULL, 'cancel_at_period_end' => false, 'canceled_at' => NULL, 'created' => 1476900796, 'current_period_end' => 1508436796, 'current_period_start' => 1476900796, 'customer' => 'cus_XXXXXXXXXXXXXXXX', 'discount' => NULL, 'ended_at' => NULL, 'livemode' => true, 'metadata' => stdClass::__set_state(array( )), 'plan' => stdClass::__set_state(array( 'id' => 'annual', 'object' => 'plan', 'amount' => 8000, 'created' => 1474521586, 'currency' => 'usd', 'interval' => 'year', 'interval_count' => 1, 'livemode' => true, 'metadata' => stdClass::__set_state(array( )), 'name' => 'Annual', 'statement_descriptor' => NULL, 'trial_period_days' => NULL, )), 'quantity' => 1, 'start' => 1476900796, 'status' => 'active', 'tax_percent' => NULL, 'trial_end' => NULL, 'trial_start' => NULL, )), )), 'livemode' => true, 'pending_webhooks' => 1, 'request' => 'req_XXXXXXXXXXXXXXXX', 'type' => 'customer.subscription.created', ))
-
Try: $mail = new \PHPMailer(); The backslash at the front tells it not to use the ProcessWire namespace
-
Under pressure from a client, I had to launch a PW front end user membership site 2 months earlier than the agreed schedule. Never an ideal situ and no time to fully test everything. The client web admin and I were able to monitor the logs, esp the session logs to see who'd logged in and who'd had trouble. We immediately emailed those who'd lost/forgotten/did-not-receive-the-email-with their username. Every single one of those new members emailed back their appreciation for the proactive customer support. What could have been disastrous turned those subscribers into site fans. PW logs are your friends! Thank you Ryan, the PW dev team and every forum/module contributor for delivering such a solid product.