Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/15/2018 in all areas

  1. It's not the Browser cache or something, but the PW page cache in memory. You'd need to reload the $user after your upload and saving image... $u = $users->get($user->id); if($u->profile_picture) { $userImg = $u->profile_picture; echo '<img src="'.$userImg->url.'">'; } Anyway I would recommend to redirect to the page after submit, but then you need to handle errors differently. Like this you would upload the form with a refresh or going back. Also I would rethink the upload folder to be in a folder not accessible from public for security reasons. You can simply use a folder in "site/assets/cache/.uploads" as . folders will get blocked by PW .htaccess. Also you could move the part with the WireUpload into your if($input->post->form_submit) { .... as it's not needed before that.
    3 points
  2. Sendy is great if your budget is small AND you need to send emails to a lot of people (10k+). Mailchimp is incredible, but the price for small business is not so good, especially when a dollar is almost 4 times your currency (Brazilian Real) ? Just keep an eye on your AWS SES reputation dashboard, for complain and bounce rates.
    3 points
  3. @MarcoPLY more info about options fieldtype there. There you go ( should support multi-language) : wire()->addHookAfter('LoginRegister::processRegisterForm', function ($event) { $form = $event->arguments[0]; foreach($form->getAll() as $f) { $name = $f->attr('name'); if(strpos($name, 'register_') !== 0) continue; if($name == 'register_subscribe_newsletter' && wire('input')->post->register_subscribe_newsletter == 1) { $options = wire('fieldtypes')->get('FieldtypeOptions')->getOptions(wire('fields')->get('shipping_countrycode')); // get the field foreach ($options as $value) { // loop if(wire('input')->post->register_shipping_countrycode == $value->id) { // check field options id $country_title = $value->title; // assign country option title } } $mc = wire('modules')->get("SubscribeToMailchimp"); $email = wire('input')->post->register_email; $subscriber = [ 'FNAME' => wire('input')->post->register_pad_firstname, 'MMERGE4' => $country_title, ]; $mc->subscribe($email, $subscriber); } } }); ?
    3 points
  4. Over the years, I accumulated so many custom API scripts, that I have decided at some point to simply include a special template in my PW boilerplate that holds all these utility / "batch-operation" API scripts in one place. In the template settings, I allow URL segments, and make sure access is for superusers only. This "API-scripts" template has (for better maintainability / readability) a simple switch/case that loads a certain .php file via include: So, if e.g. I need a quick listing / overview of all fields that a certain template has, I go to: mysite.com/api-scripts/fields - then I go back and lock the template again = comment the first few lines for security reasons (one can never be too paranoid...). For me, these are big time-savers, because even if you have to modify the included scripts for the current project, at least I don't have to search for these scripts over and over again and guess "where have I been using something similar the last time?" tl;dr: It's like having the whole PW-recipes site (and more) always at your fingertips ?
    2 points
  5. http://directory.processwire.com/map/
    2 points
  6. I added the source code on this post:
    2 points
  7. The module source is below. Example usage: a checkbox on a contact form (using Form Builder) for the user to subscribe. It's used on https://ricardo-vargas.com/contact/ EXAMPLE A method on _hooks.php. If you don't use Form Builder, use this code on your form page. $forms->addHookBefore('FormBuilderProcessor::emailForm', function($event) { $processor = $event->object; if ($processor->formName == 'contact-form') { $formData = $event->arguments(1); $contact_name = $event->sanitizer->text($formData['contact_name']); $contact_name = substr($contact_name, 0, 30); // limit length further $contact_name = $event->sanitizer->emailHeader($contact_name); $contact_email = $event->sanitizer->text($formData['contact_email']); $contact_email = $event->sanitizer->emailHeader($contact_email); $processor->emailFrom = $contact_email; //reply to $processor->emailSubject = 'Message from '.$contact_name; $form = $event->object->getInputfieldsForm(); $subscribe = $form->get('receive_updates'); $list_id = $form->get('sendy_list_id')->attr('value'); // check to see if they subscribed if ($subscribe->attr('checked')) { $success_url = '/contact'; // $fail_url = '/contact?error=1'; $ProcessSendyAPI = wire('modules')->getModule('ProcessSendyAPI'); $ProcessSendyAPI->subscribeInSendy($contact_name, $contact_email, $list_id, $success_url); } } }); MODULE https://gist.github.com/sjardim/2d834ebb0bd66d4da1ac16072f4075cd <?php namespace ProcessWire; class ProcessSendyAPI extends WireData implements Module, ConfigurableModule { public static function getModuleInfo() { return array( 'title' => __('Process Sendy API'), 'summary' => __('Handle API calls to a Sendy installation'), 'author' => 'Sérgio Jardim', 'version' => '001', 'singular' => true, 'autoload' => false, 'icon' => 'envelope' ); } /** * Data as used by the get/set functions * */ protected $data = array(); /** * Default configuration for module * */ static public function getDefaultData() { return array( "sendy_api_key" => '', "sendy_installation_url" => 'http://www.example.com/sendy' ); } /** * Populate the default config data * */ public function __construct() { foreach(self::getDefaultData() as $key => $value) { $this->$key = $value; } } public static function getModuleConfigInputfields(array $data) { $data = array_merge(self::getDefaultData(), $data); $wrapper = new InputfieldWrapper(); $f = wire('modules')->get('InputfieldText'); $f->attr('name', 'sendy_api_key'); $f->label = __('Sendy API Key', __FILE__); $f->description = __('Further instructions at https://sendy.co/api', __FILE__); $f->notes = __('Get your key at http://your_sendy_installation/settings.', __FILE__); $f->value = $data['sendy_api_key']; $wrapper->add($f); $f = wire('modules')->get('InputfieldURL'); $f->attr('name', 'sendy_installation_url'); $f->label = __('Sendy instalation URL', __FILE__); $f->description = __('Your Sendy installation URL without a trailing slash', __FILE__); $f->notes = 'http://www.example.com/sendy'; $f->value = $data['sendy_installation_url']; $wrapper->add($f); return $wrapper; } /** * [subscribeUserOrGuest description] * @param [type] $name [description] * @param [type] $email [description] * @param [type] $list_id [description] * @param [type] $success_url [description] * @param [type] $fail_url [description] * @return [type] [description] */ public function subscribeInSendy($name, $email, $list_id, $success_url = null, $fail_url = null) { $api_key = $this->data['sendy_api_key']; $sendy_url = $this->data['sendy_installation_url']; $postdata = http_build_query( array( 'name' => $name, 'email' => $email, 'list' => $list_id, 'boolean' => 'true' //set this to "true" so that you'll get a plain text response ) ); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata)); $context = stream_context_create($opts); $result = file_get_contents($sendy_url.'/subscribe', false, $context); //check result and redirect if($result) { $this->wire('log')->save("newsletter", 'A new user subscribed to the site mailing list: '.$email); if($success_url) { header("Location: $success_url"); } } else { $this->wire('log')->save("error", 'Error occurred on subscribing '.$email); if($fail_url) { header("Location: $fail_url"); } } } }
    2 points
  8. yes sorry, I edited my previous post, please re-copy the code. The error is because I use the keyword $this (as I am writing a module) instead of using wire() in the hook if he is called from the ready.php ?
    2 points
  9. thx @Robin S @elabx @flydev This works: $p = new Page(); $p->template = 'project'; $field = $this->fields->get('title'); $form->add($field->getInputfield($p)); I've had an error in my field's config (requesting dynamic data, getting a page via $this->wire->process->getPage(); and that threw an error. I thought I was doing something wrong but with the title field it worked ? Thank you! Edit: This also works: $form->add($this->fields->get('recipients')->getInputfield(new NullPage()));
    2 points
  10. hey adrian, hope you are enjoying your vacation! what do you think of adding a section in the request info panel that shows the code needed for creating this field via api (for example in process module)? $form->add([ 'type' => 'page', 'label' => __('Mail auswählen'), 'derefAsPage' => 1, // single or null 'inputfield' => 'InputfieldAsmSelect', 'template_id' => 73, // mail 'value' => 23669, ]); The request info panel has all the necessary informations: If we had a section "Field code" we could just create fields in the Backend and then copy/paste them in our modules ?
    2 points
  11. So to get it working, nothing fancy, all easy. In this example, only the email user field is used. Thanks @daniels for this module ? Assuming the checkbox field is called "subscribe_newsletter" and added to the "Registration form fields" in LoginRegister settings, in ready.php : wire()->addHookAfter('LoginRegister::processRegisterForm', function($event) { $form = $event->arguments[0]; foreach($form->getAll() as $f) { $name = $f->attr('name'); if(strpos($name, 'register_') !== 0) continue; if($name == 'register_subscribe_newsletter' && wire('input')->post->register_subscribe_newsletter == 1) { $mc = wire('modules')->get("SubscribeToMailchimp"); $email = wire('input')->post->register_email; // Do not forget to saninitize the email field $mc->subscribe($email); } } }); Result:
    2 points
  12. --- Please use RockFinder3 ---
    1 point
  13. Hi there, we are a small Communication Agency in Munich and we are searching for a Processwire Developer. A lot of our Online Projects are based on Processwire and our current Developer is switching from Freelance to a full term job. The work can be done remotely from anywhere. For more Informations please contact me directly via Email: p.kirschvink@damego.de Looking forward to hear from you. Best Paul
    1 point
  14. Sorry, lots of little suggestions today Just thinking that it might be nicer for users to see the field name in these messages. In some cases the name can be quite different from the label, which could confuse them. Session: Missing required value (Field Label) vs Session: Missing required value (field_name) I also wonder whether the "Session:" is relevant, especially for non superusers.
    1 point
  15. Hi Guys We are looking for an alternative to MailChimp for managing Newsletters, Subscribers, Campaigns, Lists etc... While searching for a new Tool I discovered Sendy. It looks like a decent Webapp/Newsletter-Tool to manage Newsletters, Lists, Subscribers, Campaigns etc... The Mails are sended with Amazon SES and it is way cheaper than Mailchimp. And it is also a self hosted Tool. Has someone some Experience and Opinions on Sendy in general and also in combination with ProcessWire (Module, Integration etc...)? Do you also know other Solutions / Alternatives rather than Mailchimp? Kind regards Orkun
    1 point
  16. Sorry for the OT question but are you referring to GDPR?
    1 point
  17. Ah perfect thanks - all makes perfect sense now you've spelled it out to me - reloading the user object solves the issue ? And yes - addressing the security issues above is in my todo list - this was just a prototype based on examples on this forum and it was bugging the hell out of me why the image wouldn't load first time!
    1 point
  18. ok this time is good, you need to put your markup after the if condition. <?php //Display current user image $upload_path = $config->paths->assets . "files/avatar_uploads/"; $f = new WireUpload('userimage'); $f->setMaxFiles(1); $f->setMaxFileSize(1*1024*1024); $f->setOverwrite(true); $f->setDestinationPath($upload_path); $f->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); if($input->post->form_submit) { if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path!"); } $files = $f->execute(); if ($f->getErrors()) { foreach($files as $filename) @unlink($upload_path . $filename); foreach($f->getErrors() as $e) echo $e; } else { $user->of(false); $user->profile_picture->removeAll(); // wirearray (line added by @horst: explanation is three posts beneath) $user->profile_picture = $upload_path . $files[0]; $user->save(); $user->of(true); @unlink($upload_path . $files[0]); } } // here $userImg = $user->profile_picture->first(); echo '<img src="'.$userImg->url.'">'; ?> <form class="forum-form" accept-charset="utf-8" action="./" method="post" enctype="multipart/form-data" > <input type="file" id="attach" name="userimage" accept="image/jpg,image/jpeg,image/gif,image/png" /> <input type="submit" name="form_submit" value="Submit"/> </form> and if you want to avoid a warning in imageExtra, then you should assign a title to the picture_profile field : [...] $user->profile_picture->title = ''; // or whatever $user->save() [...]
    1 point
  19. Please check here, you can find the full job post: https://jobs.zu-zweit.de/webdeveloper/de in German har har ? The position is in Munich and partly remote possible. If you have further questions, just let me know.
    1 point
  20. Hello @Sanyaissues , I was not aware of the reCAPTCHA v3 but it will be definitely implemented. I will wait a bit more documentation as I already tried to get it working but without success. Thanks for your interest ?
    1 point
  21. ask @Sergio if he wants to share his module?
    1 point
  22. Newsletter-Tools... the reason why I prefer Mailchimp, CampaignMonitor, and similar solutions: I don't have to invest in servers, several IP addresses and maintenance. I don't have to take care of blacklists, spam-prevention-configurations, routings and all that technical stuff. Mailchimp & Co. do this for me. They want my money and they want me to be happy with their service. Self-hosted solutions never worked for me, the companies I worked for, clients and most people I know who do newsletter-marketing. Just my opinion. It may work really well for you.
    1 point
  23. Ok, I've created a PR that does at least the first part of what I requested: https://github.com/adrianbj/TracyDebugger/pull/22 @szabesz adrian was crazy enough to implement exactly what you requested, so that's is already possible ? @adrian Regarding my PR: Not sure why, but I have an options field that does not show any information about the selectable options in the request info panel. Also I'm not sure how to work with multilanguage fields, as the inputfield seems to be always single language.
    1 point
  24. It would be easy to give an example using a Page object, but from a module I am curious how to achieve it. Another idea could be creating a page/template with all the fields which will be potentially injected in a form then $test = $fields->get('test_field'); $field = $test->getInputfield($injectPage); // $injectPage is a Page object $form->add($field);
    1 point
  25. moderator note I've moved this thread to module dev since it is no longer a support thread. I might lock it in the future if there is a need.
    1 point
  26. I've done it getting the actual Inputfield module, not the Fieldtype, I'd be very curious to see if the getInputfield method works! Get back to us on what works @bernhard :D
    1 point
  27. You can't add a Field object to a form, but rather an Inputfield object. Field::getInputfield() would come in handy here.
    1 point
  28. Our whole international website is based on processwire, we have a pretty advanced installation with several countries, domains and CDN
    1 point
  29. you should add a name or id to your submit button.
    1 point
  30. Then I think I'm gonna post it as an issue on GitHub since non-superusers shouldn't see the field names.
    1 point
  31. Hi, @flydev! Recaptcha v3 came out, would you mind taking a look?
    1 point
  32. the moment I copy these lines if($page->template == 'admin') { $oauth2mod = $modules->get('Oauth2Login'); if($oauth2mod) $oauth2mod->hookBackend(); } on ready.php I am getting this error Fatal error: Uncaught Error: Call to undefined function ProcessWire\urls() in C:\xampp\htdocs\Yush\wos\site\modules\Oauth2Login\Oauth2Login.module:72 Stack trace: #0 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(607): ProcessWire\Oauth2Login->init() #1 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(1288): ProcessWire\Modules->initModule(Object(ProcessWire\Oauth2Login), Array) #2 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(1145): ProcessWire\Modules->getModule('Oauth2Login') #3 C:\xampp\htdocs\Yush\wos\site\ready.php(13): ProcessWire\Modules->get('Oauth2Login') #4 C:\xampp\htdocs\Yush\wos\wire\core\ProcessWire.php(581): include('C:\\xampp\\htdocs...') #5 C:\xampp\htdocs\Yush\wos\wire\core\ProcessWire.php(479): ProcessWire\ProcessWire->includeFile('C:/xampp/htdocs...') #6 C:\xampp\htdocs\Yush\wos\wire\modules\Process\ProcessPageView.module(246): ProcessWire\ProcessWire->setStatus(4) #7 C:\xampp\htdocs\Yush\wos\wire\core\Wire.php(380): ProcessWire\ProcessPageView->___ready() #8 C:\xampp\htdocs\Yush\wos\wire\core\WireHook in C:\xampp\htdocs\Yush\wos\site\modules\Oauth2Login\Oauth2Login.module on line 72 Error: Uncaught Error: Call to undefined function ProcessWire\urls() in C:\xampp\htdocs\Yush\wos\site\modules\Oauth2Login\Oauth2Login.module:72 Stack trace: #0 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(607): ProcessWire\Oauth2Login->init() #1 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(1288): ProcessWire\Modules->initModule(Object(ProcessWire\Oauth2Login), Array) #2 C:\xampp\htdocs\Yush\wos\wire\core\Modules.php(1145): ProcessWire\Modules->getModule('Oauth2Login') #3 C:\xampp\htdocs\Yush\wos\site\ready.php(13): ProcessWire\Modules->get('Oauth2Login') #4 C:\xampp\htdocs\Yush\wos\wire\core\ProcessWire.php(581): include('C:\\xampp\\htdocs...') #5 C:\xampp\htdocs\Yush\wos\wire\core\ProcessWire.php(479): ProcessWire\ProcessWire->includeFile('C:/xampp/htdocs...') #6 C:\xampp\htdocs\Yush\wos\wire\modules\Process\ProcessPageView.module(246): ProcessWire\ProcessWire->setStatus(4) #7 C:\xampp\htdocs\Yush\wos\wire\core\Wire.php(380): ProcessWire\ProcessPageView->___ready() #8 C:\xampp\htdocs\Yush\wos\wire\core\WireHook (line 72 of C:\xampp\htdocs\Yush\wos\site\modules\Oauth2Login\Oauth2Login.module) This error message was shown because: site is in debug mode. ($config->debug = true; => /site/config.php). Error has been logged.
    1 point
  33. I know, that's why I'm asking how can I do it with a hook ?
    1 point
  34. I for one do not use bootstrap anymore. I got fed up with the bloat and components that I just never used. I found that I was using about 8% of what was being offered out of the box, so I started to look for alternatives. I followed a great tutorial by Chris Coyier and rolled the things I learned into my own grid system. Thus far, I really am enjoying it. If I need a slider or library, I just include it with my work flow so my grid stays nice and light. Also, if I need something in particular that my grid does not do, I simply update it to encompass it.
    1 point
  35. You can use this to check if it's not the default language and only display description in this case. if(!$user->language->isDefaultLanguage) { // display description }
    1 point
  36. $pageArray->has($page); http://processwire.c...er=has Also it doesn't matter if you add duplicates as PW will remove them anyway.
    1 point
×
×
  • Create New...