Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/19/2017 in all areas

  1. This week's post is actually last week's post, just updated with a lot of new content. Since the topic is pretty much the same as last week, I thought it fit better this way. We've continued to make a ton of progress with the export/import features over the last week, and it's all covered in the updated blog post here: https://processwire.com/blog/posts/processwire-3.0.71-adds-new-core-module/
    2 points
  2. Here's a mixin I put together for creating hamburger icons. It utilizes the checkbox hack so you can use CSS only to show a mobile menu (or off-canvas menu, etc). Unlike other mixins here you can specify a selector for the label tag if it's not directly below the checkbox, so the label (the icon) can be placed anywhere in the DOM. There is also a "hamburger_tint" helper mixin included to easily colorize the icon/text on hover or in a checked state. Parameters: width: the width of the icon. default: 32px thickness: the thickness of the bars. default: 3px gap: the vertical space between the bars. Overall height is: thickness*3 + gap*2. default: 7px color: the color of the icons. default: #000 (black) radius: border-radius value to round edges. default: 0 anim: seconds of animation duration (transition-duration) or timing function + duration (eg. "ease-out 0.3s"). Use -1 to disable morphing to an "X". default:0.25s labelselector: in case the label is not right after the checkbox, use this setting to tell the mixin where to find it. Eg. "~ div.content header nav label". default: "+ label" padding: extra spacing around the icon. default: 0 text: show text next to the icon, by default on the right. Values: "left" or false to disable. Requires an extra "span" tag. default: "right" CodePen demo GitHub
    2 points
  3. As I am writing the documentation, if you guys have already some questions before I release the module, I will be happy to hear and include them in the FAQ
    2 points
  4. i'm not sure but i think hannacode does not support the if statements like [myifstatement]this is shown only to superusers for example[/myifstatement] second, hannacode is a textformatter module that works only as a formatter for fields. i use my module to replace tags in emails and pdfs (ok that would also be possible with the textformatter and i'm thinking of adding a textformatter to call all my replacements, but i just wanted to have my own way of doing it...). and third, i prefer to define things with single files and not to write code into some field's config field. you can then use git for version control. next on the roadmap is to support else-statements like this: [superuser] access [else] sorry, only for superusers :) [/superuser]
    2 points
  5. 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); } }
    1 point
  6. @ryan As far as I can understand PageTable will be updated next week in order to support pages export/import. While you are at it, can you please consider adding a second "Add new" button to top the PageTable? I did it with this JS hack: The actual issue is demonstrated here:
    1 point
  7. Hello, today I want to introduce you to a php honeypot class that I have implemented to my forms to prevent form submissions via spam bots: https://github.com/dominiquevienne/honeypot The class creates a honeypot and a token field. It checks for time from page rendering to form submission correct token filled in honepot field failure attempts All settings can be changed via a config array (fe set min time until form submission to 5 seconds, if the form will be submitted faster it must be a spam bot,...). Just take a look at the documentation and maybe its interesting for you. Best regards
    1 point
  8. ok great, i'm hoping to test the changes and push the update to the module next week..
    1 point
  9. I always found it easier to have a page select field on my homepage. That way you have a single point for determining the featured page and don't have to trawl through a site tree to determine which page(s) are already checked.
    1 point
  10. @rafaoski You're welcome! I hope it will be useful. I've submitted new Polish language pack (for 3.X) to the official modules directory at ProcessWire, it's still pending approval, but I hope it will be approved soon. If you will find any bugs, typos, please let me know and I will try to update it. Thanks! Pozdrawiam !
    1 point
  11. OK, I found a workaround. I added a field 'formID' to my ' form_page' template . In the template, I have a single include in the body which looks like this: include ($config->paths->templates.'forms/'. $page->formID .'.php'); All my forms go into the forms directory. To render a form on a page which uses the form_page, all I need to do is set the page's 'formID' field to the form's filename. As long as I don't include any other includes within the form file above. I can live with that. I am enjoying Processwire.
    1 point
  12. How about something like this? Create a Checkbox field called featured, add it to a template Hook into Page::savedField, return if field name is not 'featured' Check if $page ($page = $event->arguments(0)) has $page->featured=1 Perform a $pages->find("featured=1, id!=$page") Iterate over those pages and set featured=0 Now one potential problem that comes to my mind is that as you're iterating over these pages, the hook will be called over and over. Setting $event->cancelHooks = true before you do the iteration should cancel subsequent hooks, but I haven't tried it.
    1 point
  13. OK, so I guess this is definitely a facepalm Friday... I was playing around with hooks lately. And one of those hooks created emails to notify me whenever a certain page-type was edited/created. Today, I had to create several pages via API. Worked out all nicely and all... till I realized that I have also sent out some 20k email notifications. Within 1-2 hours. This of course notified the hosting company, and they disabled WireMail altogether. After a phone call with the hosting company, they put the chmod back to 0644. I disabled that hook and everything is smooth sailing again... Feel free to add your own personal favorite facepalm.gif here... mea culpa... and TGIF!
    1 point
  14. Hi @ryan, I just wanted to say thank you for the fantastic updates you've included. I recently had to export/import some pages from prod to dev for testing using the new module, and it all seemed to work magically. Great job! I'm looking forward to using this more.
    1 point
  15. I played around a bit with custom JS based Input. Here are the settings for 3 individual JS based input options: ColorPicker by Stefan Petr (http://www.eyecon.ro/colorpicker/) initial JS $('#{id}').ColorPicker({ color: '{value}', onChange: function (hsb, hex, rgb) { $('#{id}').attr('value', '#' + hex); } }); include JS colorpicker/js/colorpicker.js include CSS colorpicker/css/colorpicker.css JSColor by Jan Odvarko (http://jscolor.com/) initial JS var input = document.getElementById('{id}'); var picker = new jscolor(input); include JS jscolor-2.0.4/jscolor.js Color Picker (http://dematte.at) initial JS $('#{id}').colorPicker(); include JS dematte/jQueryColorPicker.min.js Pull js file from here: https://github.com/PitPik/colorPicker/blob/master/jQuery_implementation/jQueryColorPicker.min.js
    1 point
  16. This is what I ended up doing... On each of my templates I added an include to languages.inc and in languages.inc I have the following... <?php $languages_array = array(); foreach ($languages as $language) { $url = $page->localUrl($language); $languages_array[] = array( 'url' => $url ); } $language_json = json_encode($languages_array, true); ?> <script> var languages = <?php echo $language_json; ?> </script> Then in my JS wrote a function that updates the values of the language switcher URL from the json outputted per page load. function languagesUpdate() { var language1Url = languages[0].url, language2Url = languages[1].url; $('aside.main ul.languages li').eq(0).find('a').attr('href', language1Url); $('aside.main ul.languages li').eq(1).find('a').attr('href', language2Url); } Then I called this function when the AJAX was successful and seems to work a treat. Maybe this'll help someone!
    1 point
  17. Looks like I found the answer here on the forums: So now my path has: <base href="<?= $config->urls->templates ?>" /> in the header section, and from there I can simply type "images/photo.jpg" in my field.
    1 point
  18. @Peter Knight - where have you been?
    1 point
  19. @benbyf Tested and confirmed you can do this. Simple example (no paging although that's possible too): <?php namespace ProcessWire; use Kunnu\Dropbox\Dropbox; use Kunnu\Dropbox\DropboxApp; use Kunnu\Dropbox\DropboxFile; $drop = $modules->get('DropboxAPI'); //Configure Dropbox Application $app = new DropboxApp($drop->app_key, $drop->app_secret, $drop->authorization_code); //Configure Dropbox service $dropbox = new Dropbox($app); $listFolderContents = $dropbox->listFolder(""); //root folder is the folder you nominated in the Dropbox App config. Refer doco $items = $listFolderContents->getItems(); ?> <ul> <?php foreach ($items as $item) : ?> <li><?=$item->getName()?></li> <?php endforeach; ?> </ul> As for download links, you could use the Dropbox Chooser https://www.dropbox.com/developers/chooser#javascript or create your own with javascript.
    1 point
  20. @ComputerKid the SkyScraper profile is what several persons (including me) used to disect the code and find out about the power of PW Api. Please, do yourself a favor and do not just install the profile, but have a look "under the hood" and try to assimilate what, how, why etc. I can guarantee you that quite soon you will realize that Wordpress has also nothing comon other than being developed under PHP I worked myself on Wordpress for quite a few users (as an end user) and was not even able to edit some scripting parts to add custom fields etc. Now with PW in zero time I started developing my own theme with quite extensive functionality. And there is so much more to improve my coding skills, so just search the forum, search in google for ProcessWire and you will be more than good to add what is needed to your website
    1 point
  21. Yeah, Console is a part of @adrian's Tracy Debugger. It's a great tool to keep under your belt. http://modules.processwire.com/modules/tracy-debugger/
    1 point
  22. You could make use of the repeater field to achieve this. You simply create the repeater and assign it the fields in questions, and the customer could add them quite easily. https://processwire.com/api/fieldtypes/repeaters/ Example <?php foreach($page->articles as $article) { echo $article->some_field; } ?>
    1 point
  23. 7Studio ... Great Thanks for the Language Pack ... Dzięki Jeszcze Raz ( Po Polsku ) ...
    1 point
  24. Here's what I did. I set up a Page Reference Field, where client can pick a parent. This means with $page->related_random I can get the parent. Getting its children is simply $page->related_random->children->find(). I then iterate over them and output some data
    1 point
  25. I think I get it now. You want to group children by values of a column Something like this one works: So this code $parent = $pages->get(1017); $groupedByLow = []; foreach($parent->children as $child) { foreach($child->prod_vid_bandwidth as $item) { $groupedByLow[$item->band_lo][] = $child->name; } } ksort($groupedByLow); // sort by band_lo dump($groupedByLow); Groups children like this (I used name field for presentation) array (3) 10 => array (1) 0 => "new-car" (7) 20 => array (2) 0 => "old-car" (7) 1 => "new-car" (7) 60 => array (1) 0 => "old-car" (7) You may need to check for null inside the second foreach.
    1 point
  26. If you define the namespace on top of your script, you wont have to prefix functions with \Processwire\ #!/usr/bin/php <?php namespace ProcessWire; // remember to include namespace include("./index.php"); // bootstrap ProcessWire // ... function createMockUsers() { $u = new User(); $u->of(false); // short for outputFormatting // inside closure you cannot access global $wire variable // unless you set function myFunction() use ($wire) {} // but you can call wire() function instead $u->name = wire()->sanitizer->pageName("newname"); $u->pass = "yo12345"; $u->email = wire()->sanitizer->email("example@processwire.com"); $u->addRole('guest'); $u->save(); } // ... createMockUsers();
    1 point
  27. Now, the "package manager"; From this window, you can create or delete a package, and also download a packages from the "server backups folder" to your computer. But the best feature is that you can "sync" packages stored on a third-party provider. This mean that the module will check for existing packages on GoogleDrive, Dropbox or whatever (it depend on how you configured Duplicator) and list them so you can delete or download them to your computer, and deploy your nice website in a minute! In the following example, I have packages on my Local Server, on GoogleDrive and Dropbox :
    1 point
  28. Done. I've made a pull request. https://github.com/processwire/processwire/pull/82
    1 point
  29. speaking of download icons – there is a (probably not used much, but nonetheless awesome) module called Secure File - for that module, the download button doesn't work, i guess AOS is not compatible with that module; I disabled the "Add Asset Download Button", since that module already provides a download link for the file. Just wanted to post that here in case someone else uses secure file and comes across the non-working download (if they have AOS add asset download enabled)...
    1 point
  30. szabesz, have you ever tried writing a custom process module? sometimes it's a lot easier to write your own custom admin-interface than modifying the regular page edit form it's easier than you might think!
    1 point
  31. https://www.baumrock.com/portfolio/hr-diamonds.com/ I built this website for my client hrdiamonds.com - a great HR company based in Vienna, Austria. They were totally unhappy with the result of the former agency so it was easier to rebuild the website from scratch than adopting the old CMS (that was actually only 2 years young!)... Design by @lokomotivan built with UiKit Highlights: Frontend-Editing barba.js for smooth page transitions ProCache, of course Favourite client quote of the CEO: Happy to hear your feedback
    1 point
  32. I built this module because I needed a versatile solution to replace tags and simple if-blocks in some E-Mails and PDF documents. If you only need to replace static tags (no if-conditions), then you can use default PW api and need no module: $str = "My favourite color is {color}."; $texttools = $sanitizer->getTextTools(); echo $texttools->populatePlaceholders($str, ['color' => 'red']); // output: My favourite color is red. Usage: See the two example Files in the folder /replacements Methods: replacementsTable() Renders an overview of all available replacements (see the example in the Module's config file: Create new Replacements: Simply copy the sample file and adopt to your needs. Download: https://gitlab.com/baumrock/RockReplacer
    1 point
  33. one more complex example: in the pdf creating module: $mpdf->WriteHTML(modules('RockReplacer')->replace($block->body, ['report' => $this->report])); the users edit-screen: the users help-section: the resulting pdf: and the replacementfile: <?php namespace RockReplacer; class dataoverview extends Replacer { public function desc() { return $this->_('Fügt eine Tabelle mit einer Zusammenfassung über alle Feedbacks + Rollen ein'); } public function replace($vars) { $report = $vars['report']; $project = $report->closest('template=project'); $fn = $report->fn; ob_start(); ?> <div class="dataoverview"> <h3><?= $this->_('Feedbackübersicht'); ?></h3> <table class="size-psmall striped"> <tr> <th class="text-center"><?= $this->_('Rolle'); ?></th> <th class="text-center"><?= $this->_('Eingeladen'); ?></th> <th class="text-center"><?= $this->_('Abgegeben'); ?></th> <th class="text-center"><?= $this->_('Rücklaufquote'); ?></th> </tr> <?php foreach($report->getRoles() as $role): ?> <tr> <td><?= $role->title ?></td> <td class="text-center"> <?php $invited = $this->wire->pages->count( "template=feedback". ",has_parent=$project". ",fn=$fn". ",fbrole=$role" ); echo $invited; ?> </td> <td class="text-center"> <?php $done = $this->wire->pages->count( "template=feedback". ",has_parent=$project". ",fn=$fn". ",fbrole=$role". ",fbdone=1" ); echo $done; ?> </td> <td class="text-center"><?= $invited ? round(($done/$invited)*100, 0) : 0 ?>%</td> </tr> <?php endforeach; ?> </table> [...] </div> <?php return ob_get_clean(); } }
    1 point
  34. Horst and I would like to announce the release of v1.0.0 of the WireQueue suite of modules. There are now drivers for textfiles, redis and SQLite and the interface has been extended to include the isEmpty(), purgeItems() and getItems() methods. Enjoy!
    1 point
  35. Thanks for the link to Anttis writeup. ------------------ Following is a description for what the SQLite handler was used in the past before I built WireQueue around it. One use case was for an award winning Cinemaportal where they send up to 2x 13k emails in different newsletters every week. I should embed the WireMailSMTP module there and I suggested that we should use SQLite files for it. This is running a half year in production now without any problems. At the beginning we have had a testing for 2 weeks where we slightly modified and tweeked some little parts. On that server where the website is hosted were running many many different programs and services, so, that for unknown reasons, sometimes the SQLite DB stopped working unexpected. But SQLite has a sort of transaction feature (Sqlite-Journal files), so that no recipient got lost. On every run we retrieve 500 pending recipients. The only thing what could happen there was, that, when immediately after successful sending a mail and the SQLite crashed before it could update the record in the dbfile AND in the journal file, this single recipient will be picked up again with the next batch, what results in sending him the newsletter twice. So, this (only) happened a few times per week, (3-10) on 10k mails, = 0,1 percent. And as this may be a bit specific to that explicit server, as I haven't encountered it with other use cases, it seems to be much more secure to use SQLite with its transaction / rollback functionality as MySQL with MyISAM! Don't know about the differences when using MySQL and InnoDB. But we / you can build storage handlers for every DB we / you like. So, what I have done with building WireQueue, is implementing it for easy usage and monitoring in PWs backend. The previous used fieldsdefinition of the SQLite table has changed from userid, email, sent, tries to data, state, worker, but everything else of the SQLite part is identical in WireQueue. Hope this helps a bit.
    1 point
  36. Hey mr. Ivan! Nice to hear from you. There can be some different usecases. Normally you want to use a Queue for decoupling time intensive tasks from the websites responses so that the users doesn't have to wait long times. For example, if someone booked / collected something on a site, there will finally an email sent to him / her. If the script would wait until it could connect to the smtp server and has sent the email, it could be that the smtp server is busy and delays the sending. With a Queue, you simply drop in this job and give fast response to the users screen: "Thanks for your booking! We will response by email soon.". Another script will pickup the job and proceed it. So, decoupling time intensive tasks and optionally split up the work to multiple workers if usefull / necessary. Another example would be sending a newsletter to 5k recipients. It seems better to me to have those temporary data seperated from the main Database in regard of Backups / Restores. With WireQueue you can create and controll Queues visually in the backend. This wouldn't be necessary but I found it usefull and comfortable. Currently there is only a very simple StorageModule available with plaintext files. The next one uses SQlite Databasefiles what is much more comfortable as it opens the WireQueue to not only put and get jobs into it but also can be used to store the current state of each job. Or if the collected data should be exported to other systems for further processing, etc. You can use whatever storage type you like. You only needs to create your own storage module upon the abstract class that comes with the module. Currently there are only comments in the code itself and the WireQueueTextfile module for detecting how it should be done. But it isn't complicated. You can setup one that uses a MYSQL table in another DB than that from your PW installation. etc. etc. More and better information will come later in next step. Does that help?
    1 point
×
×
  • Create New...