Jump to content

psy

Members
  • Posts

    620
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by psy

  1. There are many. I trawled the FB forum on the assumption my requirement wasn't unique Here's one:
  2. 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); }
  3. psy

    Rockpool Painting

    @Macrura Thanks, sorry for the late reply, just saw your comment. Forgot to add album template to MarkupSEO allowed template list. Fixed
  4. 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)
  5. Same for me Thought maybe it was a $config setting but couldn't find anything. Suggestions?
  6. @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
  7. 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
  8. Thanks Robin, forgot about the <region> tag. Good call!
  9. 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
  10. 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.
  11. psy

    Rockpool Painting

    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'); });
  12. psy

    Rockpool Painting

    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
  13. 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+ ...
  14. 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
  15. 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!
  16. psy

    Lazycron Hooks

    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.
  17. 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', ))
  18. Try: $mail = new \PHPMailer(); The backslash at the front tells it not to use the ProcessWire namespace
  19. psy

    ProcessWire rocks

    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.
  20. Looking to hook up with a PW expert mentor on an ad hoc basis. Immediate requirement is to help refine my coding for a small but complex site. Site integrates with: - Stripe (created a module to work with the Stripe API for subscriptions). Unfortunately in this case, Padloper only works with once-off product sales. - BigCommerce shop (created a module to work with the BigCommerce API to assign subscribed PW members to a BC customer group & when a logged-in user clicks a on front-end link in PW, redirect & auto-login the user to the BC shop) - Campaign Monitor (created a module to work with the Campaign Monitore API to assign subscribed PW members to a CM List) - CMS Made Simple - Main site built in CMS Made Simple (header & footer pulled from CMSMS to display on the PW site on the same domain + some content). Ideally long term, main site will be converted 100% to PW. - Viddler (no module, simply an included PHP file to access the Viddler API to pull site-restricted videos) Site is built on ProcessWire 3.0.24 devns © 2016 using PHP v5.4.35 Immediate requirements: 1. Get site-initiated emails to send correctly using ProcessWireSmtp. Connection is OK and some emails go through but not all??? 2. Stripe web hooks not working on live site but did on development site User custom field not updated on receipt of Stripe hook event OR event not received at all 3. LazyCron does not seem to be working. Cache is recording times, etc but no notification emails being sent. Maybe related to point 1 or I have stuff in the wrong place. 4. Need front end 'Forgot Password' to work. Tried module FrontendUser but it wasn't satisfactory and have reverted to FormBuilder with custom layout, PW 3.0+ option D, for login (in dev not yet on live login page). Ideally ForgotPassword would work for either user entered username or useremail. Done thanks to Am sure I could post my issues in the forum but would rather solve these problems first then help others with "how to" forum posts. Be my ProcessWire guru & PM me with your experience, hourly rate etc. Cheers psy
  21. Oh, yes you're correct. According to the reference, addresses are associated with Organization, not localBusiness. I will fix and update the module. https://developers.google.com/schemas/reference/types/Place https://developers.google.com/schemas/reference/types/LocalBusiness Thanks for bringing this to my attention.
  22. I have this error alert problem with a site as well. I have narrowed the issue down to the following circumstances: The front end templates use Bootstrap but have no modal popups The problem only occurs when logged in as an admin The problem only occurs on pages that are 4th in the page hierarchy, ie: + Home ++ Blog +++ Category ++++ Blog article (error alert occurs on this page) For example: http://www.mysite.com.au/blog/categories/my-article/ It's not a showstopper on this site but is annoying. Site uses: - ProcessWire 3.0+ - PHP 5.6 HTH tracking down the cause.
  23. Wasn't sure where to post this so chose this forum as not sure whether it's unique to my scenario, a bug, something I've done wrong or a suggestion for a PW change. Scenario is: - TLD has a website built with another CMS with it's own .htaccess - ProcessWire section is in a sub directory - 99% of everything works fine except for Lost Password module - using FrontEnd user module and had similar problems with the Login form but managed to resolve by changing the form action to the current page url in the page template What happens: - using FE User module, when I click the Lost Password button and enter a valid username, the form returns FALSE and just re-displays the Lost Password form - using FE User module, when I enter an invalid username (eg user email), the page displays the message that an email will be sent - no email is ever received as the username does not exist in Users - took a step back and just used the Lost Password in the normal PW admin - entered valid username and message was displayed but no email ever received - sometimes (didn't catch the exact scenario), the page redirected to the TLD/other CMS home page What I've noticed is that in the code for LostPassword module (and others), instead of the form action returning to the current page it's hard coded as ('./?forgot') or in other FieldtypeForm modules just ('./') That's OK if PW is installed in the root dir and the home page has the code necessary to handle the responses. Changing $config->urls->root or PW .htaccess doesn't have any effect (maybe because root .htaccess governs other CMS?) Anyhoo, my question is: Would it not be better instead of hardcoding the form action as './' to use $config->urls->root , $pages->get(1)->url or even $page->url? Using: PW 3.0+
  24. I'm developing a module to integrate BigCommerce's Stores API (https://developer.bigcommerce.com/api) with PW. After a steep learning curve, I managed to use composer.json to download the latest version of the API into a 'vendor' directory. { "name": "processwire/processwire", "type": "library", "description": "ProcessWire CMS/CMF", "keywords": [ "cms","cmf", "content management system" ], "homepage": "https://processwire.com", "authors": [ { "name": "Ryan Cramer", "email": "ryan@processwire.com", "homepage": "https://processwire.com", "role": "Developer" } ], "require": { "php": ">=5.3.8", "ext-gd": "*", "bigcommerce/api": "*" }, "autoload": { "files": [ "wire/core/ProcessWire.php" ] }, "minimum-stability": "dev" } Using composer.json and its autoload.php feature works great. All I need in my template is: <?php use Bigcommerce\Api\Client as Bigcommerce; Bigcommerce::configure(array( 'store_url' => 'https://www.mybigcommerceshop.com', 'username' => 'admin@mybigcommerceshop.com', 'api_key' => '8fab84ce1776dbba18665xxxxxxxxxxxxf' )); $ping = Bigcommerce::getTime(); if ($ping) echo $ping->format('H:i:s'); My dilemma is that the files are in './vendor', not './site/modules'. Not everyone will use composer.json so looking for recommendations on how to best code the module to first look in './vendor', then if nothing there, look into './site/modules/BigCommerceApi/Api' to load the files (which may be out of date) and instantiate the API. Suggestions? Using: PW v3.0.24
×
×
  • Create New...