Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/02/2016 in all areas

  1. Excellent write-up Ryan! Here's a quick tip. If you are processing large amounts of data, you should always use PW's field joining options to achieve maximum performance. Even if you only use a single field, you should get around 50% faster execution when the field is joined straight away. With two fields joined, the execution time will be cut into half (i.e. 100% increase in speed). Let's say you need to export the e-mail addresses of thousands of customers. Here's a simplified example using "on-demand" join // Prepare a pointer for writing the output $fp = fopen('customers.csv', 'w') or die('Failed opening the file for writing'); // Ask PW to join two fields (the regular find() also supports this). $options = ['loadOptions' => ['joinFields' => ['customer_email', 'customer_number']]]; // Searching for imaginary customers $selector = 'template=customer'; // Find the pages using the new method foreach($pages->findMany($selector, $options) as $page) { // Write the data in CSV format fputcsv($fp, [$page->customer_number, $page->customer_email]); } // Free the pointer fclose($fp); As a reminder, you can also force some fields to be always joined (through PW admin). @Joer: That is pretty much what the implementation of findMany() does behind the scenes. However splitting the job into smaller batches still makes sense if you use multiple workers to process the data (e.g. for MapReduce or whatever) or if the execution time of your script is limited.
    11 points
  2. Hello, its been a while since i posted new website build on processwire so here we go Build on Processwire 3.0.12 devns with proCache. Thanks Ps. Content entry is still in progress. http://claymeeples.com/ Screenshot:
    10 points
  3. BEAUTIFUL!!!! Thanks guys! Each time I have a question I end up liking ProcessWire more and more! Everything can be reached just around the corner. I think that "ã = a" should be default. It's strange everything working BUT that one. By the way, it's: Admin > Modules > Core > InputfieldPageName Thanks again for the quick response.
    4 points
  4. It took some time but now it's possible to use a textformatter e.g. markdown parser. This is only available in branch develop for PW3.x. There is a little issue due to focus textareas, I created a PR to solve this. How to use it: go to field settings, enter some other fields, save. Reopen ImageExtra tab, now you can see a table below in which you can define one textformatter for each extra field. All installed text formatters will be listet in this dropdown.
    4 points
  5. This might be useful to anyone trying to convert a (single) existing file field to a secure one, while maintaining integrity of other file fields on the same pages. Put a file with this content in pw's root directory and run it from the terminal: <?php include "index.php"; // allow for: $ php filename.php fieldName $fieldName = !empty($argv[1]) ? $argv[1] : 'file'; $field = $fields->get($fieldName); $usedInTemplates = $field->getTemplates(); $fp = fopen('files.txt', 'w'); // the use() statement allows for both pre and post pw 3.0 usage without change/compiler $eachPageUncache = function($selector, callable $callback) use ($pages) { $num = 0; $id = 0; while (true) { $p = $pages->get("{$selector}, id>$id"); $id = $p->id; if(!$id) break; $callback($p); $pages->uncacheAll($p); $num++; } return $num; }; try { // Alternatively use findMany and a foreach on PW 3.0.19+ $eachPageUncache("template=$usedInTemplates, include=all, check_access=0", function($page) use($fp, $fieldName, $config) { $files = $page->getUnformatted($fieldName); foreach ($files as $file) { $path = str_replace($config->paths->files, '', $file->pathname); fwrite($fp, $path . PHP_EOL); } }); } finally { // PHP 5.5+ fclose($fp); } Then you can use the created files.txt to copy files to their new location (add --remove-source-files to also remove the source files). rsync -v \ --files-from=PW_ROOT_PATH/files.txt \ PW_ROOT_PATH/site/assets/files NEW_LOCATION_PATH Switch the file field to be a secure file field and all files should still work.
    4 points
  6. Hi Makari, Being the developer of Jumplinks, I haven't used ProcessRedirects in a long time, so not sure if it supports query strings, but Jumplinks does. Once installed, the redirects above should work just fine for you. Jumplinks is, in fact, quite simple, but may come across a little more complicated because it has more features and more options to choose from. That said, you can use Jumplinks the same way you would use ProcessRedirects. Just create a new Jumplink, and specify the Source URI and Destination URI/URL/Page. Please give it a try and let me know if it works for you. Note that this could also be done with htaccess and mod_rewrite, but you don't want to get caught in the position where the htaccess file gets updated by ProcessWire and your redirects disappear.
    3 points
  7. I've already thought of a filter box. Here's a screencap of its current state but it's still in an early stage. It's capable of searching image names, descriptions (multilanguage) and tags, and multiple strings at once (separated by spaces). Filtering worked fine only until name/tag/description were unchanged because filter targets were added on load. I solved this by clicking or focusing on the filter box re-adds all the filter targets. In fact all the filters are added only on the first click so if you don't use the filter it won't add too much overhead.
    2 points
  8. If you're interested in running ProcessWire using PHP's built in Webserver this one's for you: <?php /***************************************************************************** * Router script for emulating Apache's "mod_rewrite" functionality. * This router script is designed for testing ProcessWire instances quickly. * Don't use this script and/or PHP's built in Webserver in production. * * Usage: php -S localhost:8000 -t /ProcessWire /ProcessWire/routing.php *****************************************************************************/ $uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)); if ($uri !== '/' && file_exists(__DIR__ . $uri)) return false; $_GET['it'] = $uri; // emulate index.php?it=$1 require_once __DIR__.'/index.php'; Enjoy!
    2 points
  9. Have you tried adding this character to the Page Name module's settings? (under admin-modules-core I guess)
    2 points
  10. FieldtypeSelectFile & InputfieldSelectFile Inputfield Select File is an Inputfield & Fieldtype to select a single file or folder and stores the name and / or use the selected file as page template. The last option enables the editor to use multiple views for a page, depending on the selected template. Settings The folder containing the files and/or folders.A relative path relative to the /site/templates/ folder. Hide file extensions Hide files Hide folders Natural Sort (Select options)Sort files and folders in natural ordering (PHP >= 5.4.0) Change Page Template Just before the Page::loaded event the selected file is set as template file for the page. This setting can only be applied once per a page and folders are exluded from the select inputfield. Note that a page with no associated template file will render with the selected file. When to use ? Let editors select a file and base your own logic upon this. With the change page template setting you're able to use the selected file as template file. This could reduce the amount of normal templates needed and let editors choose how the page get rendered. There are plenty of use cases for this Inputfield. In the examples I call the field selected_file. // let the editor choose a CSS file $config->styles->append($config->urls->templates . "styles/" . $page->selected_file); /** * advanced usage example * * You need multiple ways to render your markup. Let the site editor choose which * file the page need to render. * */ $tpl = new TemplateFile($config->paths->templates . "includes/" . $page->selected_file); $tpl->set('current', $page); $markup = $tpl->render(); (It could be a real good companion with InputfieldSelector) Download at GitHub Modules directory
    1 point
  11. Innobloom Fast multilanguage site that features lazy loading assets, custom forms and a little bit of parallax. It features about all the goodness I gathered in the past year or two about ProcessWire and web development in general. We were trying to achieve a high google page speed score. That's why we added ProCache, though at first I was a bit sceptic whether it could improve anything as I had my own ways to speed things up: Using srcset and bgset for images with lazy loading (lazyload.js). To achieve this, I created my own functions to render the markup, and it has been released as MarkupSrcSet module later. Lazy loading JavaScripts. This is a technique I used frequently recently: adding a tiny inline "loader script" to the page which loads all the other required js files in order. In certain cases some CSS files are also loaded by JavaScript, mostly for plugins that don't have immediate visual impact. This eliminates render blocking scripts/stylesheet issue. Vanilla JavaScript. I try to use jQuery only if it's absolutely required, for example when having to use a plugin that has no plain JavaScript alternative. Most things can be easily achieved with no framework and the number of dependency-free plugins are also increasing. Often it requires only a few lines to get the required feature. For example the parallax effect on the top is only a few lines. Latte template engine. This is mainly for making development and templating easier, but also caches pages. This was one of the projects where I tested my newborn TemplateLatteReplace module which was released recently. Forms: NetteFormsHelper. This is a form module that uses Nette Forms. In this project I added useful features to it like character counter, date picker, notice when leaving the page with unsubmitted form data, autocomplete inputs, honeypot field and textarea autosizing. All these features uses plain JavaScript and assets are lazy loaded (and only when they are used on the page). All these add up to a lightweight but very powerful form module. No more frustration when having to add a form - apart from those days when I figure out to implement a new feature Keeping CSS as small as possible and adding it to the head. I used Susy here and the site's CSS is about 24 kbytes. To achieve such a small size I didn't use any framework. Imho using no CSS framework is better on the long run, at least in projects like this. I know that CSS is not cacheable this way but as long as there's no non-hacky way of loading CSS async and without FOUC it's fine for me. The usual .htaccess speed improvements, including ProCache additions ProCache Without ProCache we could achieve about 92-96 page speed scores. While it was pretty good (partly because of Latte) it was still not he score we wanted to see. Then ProCache was activated and boom! - 98/98. In fact this could be considered as 100/100 because there's only Google Tag Manager and Analytics scripts that reduced the score, and being remote assets we have no control over it. Modules The site is running on PW3. Notable modules used: ProCache MarkupSEO ProField Matrix Repeater (new favorite) Tracy Debugger Multivalue Textformatter Batch Child Editor (mostly for deleting test form submissions) Let's Encrypt HTTPS is achieved using Let's Encrypt. In fact this wasn't available on the host provider but after our inquiry they developed a cPanel module for it. We really appreciated their flexibility and open-mindedness. Templates There's only three template files on the site, and two of them are identical as they share the same fieldgroup. The basic-page template decides which page is the current, and adds additional variables/forms that are passed to the view file. I'm pretty happy with this site. It's fast, snappy and easy to maintain. As for the latter, Matrix Repeater does a nice job on allowing adding content blocks to the page on which the developer have full control - no more CKEditor WYS-is-for-sure-not-WYG madness! And the conclusion is: don't waste time to over-optimize a site. Reaching a reasonable speed is good enough, further optimizations will only make maintenance more and more harder (not to mention the frustration it causes). Anyway, it's useful having a project like this to get familiar with the current speed improvement techniques. https://innobloom.com/
    1 point
  12. yesterday i found out a very nice feature of sublime called "code folding". maybe it's not new for some of you, but it was for me and makes working a lot more comfortable. you can fold your code depending on levels: CTRL + K, then CTRL + 2 will fold on level 2: when you have your cursor inside a method, it will stay expanded. you can then fold your method on level 3: CTRL + K, then CTRL + 3: that's really nice. you can also find it in the menu under edit > code folding another great feature of sublime is multicursor. i guess most of sublime users know that... so i thought i start a new topic where we can share nice tipps and tricks for sublime and the work with processwire do you have any? ps: https://processwire.com/talk/topic/4203-sublime-text-2-snippets-for-processwire/ https://processwire.com/talk/topic/1888-sublime-text-2-course/
    1 point
  13. The suggestion by gebeer can achieve that markup - you just need to modify the PHP used in the Hanna code. If you consider it's not user friendly to type the Hanna code then you can make use of the Hanna Code Helper module. If you wanted to support multiple galleries per page and don't want to worry about the 'show' limit in gebeer's code it occurs to me that you could create a repeater field, the template for which contains only an images field. Then your Hanna code could get then nth repeater item (as specified by the user in the Hanna tag) and output its images. Shouldn't be too difficult to code. Downside is the user would need to be instructed not to reorder gallery repeaters after they are in use. ...the template for which contains a title field and images field, and the the Hanna code finds the gallery by title. That said, to do this type of layout (and an infinite number of others) properly I recommend the Repeater Matrix - it's a pro module but well worth the cost.
    1 point
  14. I have both actually. Though Paytrail is implemented with their merchant channels (myyntikanavamalli), so that one would require minor adjustments to work for simple solo seller. Not yet published, but code is available if you need.
    1 point
  15. You're right. My test was not done well. I can't even insert an u with ~ through my keyboard because it doesn't exist in the portuguese language. I was inserting the page title field and watching the page name field for the result. You're absolutely right.
    1 point
  16. There's also this one https://github.com/ryancramerdesign/ProcessWire/pull/1180
    1 point
  17. We can propose that on Github. Done. ... and thanks for noting where the module is (and what its correct name). I know that we have this, but everytime I need it, forget how it is named and where to find it.
    1 point
  18. Check out http://yourdomain.com/admin/module/edit?name=InputfieldPageName tpr was faster
    1 point
  19. Right, of course! Silly me... When requesting /?something, it's actually a request to the home page, which exists. Because it exists, Jumplinks can't touch it. So you'll need to use htaccess for these. Place the code block below directy underneath RewriteEngine On. RewriteCond %{QUERY_STRING} ^lhre_Ansprechpartner/?$ [NC] RewriteRule ^$ /ihre-ansprechpartner/ [QSD,R=302,L] You'll need to do this for each redirect you want. Alternative using Jumplinks: If you want to do this in one fowl sweep using Jumplinks, then you only need to do the following: Instead of the above condition and rule for each URI, use this only: RewriteCond %{QUERY_STRING} ^(\w+)/?$ RewriteRule ^$ /_redirect/%1/ [QSD,R=302,L] Then create a jumplink with the following: Source: _redirect/{path}/? Destination: {path}/ Now, requesting domain.com/?lhre_Ansprechpartner/ will first redirect to domain.com/_redirect/lhre_Ansprechpartner/ and then Jumplinks will convert that to domain.com/lhre-ansprechpartner/. Please let me know if that works. Edit: I see that your destination URLs differ. So instead of using the {path} wildcard, just create the jumplinks using the format shown above. So for the first one, the source would be _redirect/lhre_Ansprechpartner/? and the destination would be lhre-ansprechpartner/.
    1 point
  20. Ok it was just a question to confirm my readings of your sourcecode... For now i like to go the simple route and set the sanatizer if i get a value like in your docs described: // Get sanitized value with changed sanitizer $form->fhValue($fieldname, 'text'); for additional validation i just use simple additional functions - just what i need: http://www.maheshchari.com/60-validation-functions-with-php-2-part/#function_rangevalue Thank you for your answer and as information i use your modules on 3.0.18 without problems! Best regards mr-fan
    1 point
  21. You mean mark deleted all + sorting buttons? The first one alone seems superfluous as there is already a way to do it, even if it's not that obvious (double click on trash icon). But with sorting buttons it makes more sense. So you give me permission to use your module's code?
    1 point
  22. I have a setup where users can enter some Hanna Code in the editor which will be replaced by a gallery that contains all images on that page or a chosen number of images. This is my Hannacode PHP <?php $images = $page->images; // name of your images field if ($images->count) { $config->scripts->add($config->urls->templates . "bower_components/fancybox/source/jquery.fancybox.pack.js"); $config->styles->add($config->urls->templates . "bower_components/fancybox/source/jquery.fancybox.css"); $showcount = ($show == "all") ? false : $show; $gallery = "<article class='gallery row'>"; if($showcount) $images = $images->find("limit={$showcount}"); foreach ($images as $i) { $thumb = $i->size(300, 300); $desc = ($i->description) ? $i->description : $page->title; $gallery .= "<div class='col-md-4'> <div class='thumbnail'> <a class='fancybox' rel='group' href='{$i->url}'> <img src='{$thumb->url}' alt='{$desc}'> </a> <p class='caption'>{$desc}</p> </div> </div>"; } } $gallery .= "</article>"; echo $gallery; Hanna Code to insert into the editor: [[gallery]] // shows all images [[gallery show=6]] // shows first 6 images Settings in Hanna Code module With this solution users cannot choose the images for the gallery from within CKEditor but it takes images from the images field of that page. This should get you started. Obviously you'd need to adjust script paths and markup (I'm using Bootstrap 3 here)
    1 point
  23. I've just run some tests using HTTPS/2 and added the results and more information in an article here: http://benbyford.com/articles/https-2-for-web-designers/
    1 point
  24. Two of my favorite keyboard shortcuts so far in Sublime Text are: ⌘ + D: Select word - Repeat to select next occurrence ⌃ + ⇧ + W: Wrap Selection in html tag (or ⌃ + W for choosing the html tag) Of course there are much more.
    1 point
  25. Hi @RobinS - thanks for the report - I am still away from the office and don't have a chance to test properly right now so not sure if I am on the right track, but would you mind testing the attached version of ProcesswireLogsPanel.inc (attachment removed as it is now available as part of the Github repo) - based on the error message I think it should fix things, but you mention the error is in all panels, however I think the error is likely just propagating through and is really on coming from this file. Let me know if this works - if it doesn't, I sort it out properly when I am back in the 8th of June. Thanks!
    1 point
  26. I'm with bernhard on using Scotchbox. I started using it a while back and it was a great entry point to learning the not so mysterious methods of Vagrant. Plus, I've always been a fan of Ubuntu but being mobile is a must so I've learned to enjoy its presence as a VM on all my Windows devices. I use Scotchbox across Win 7 to Win 10 on multiple devices including Surface Pros and it has always worked out of the box. Once projects are done I just destroy the box because I push everything to GitHub anyway. I used to configure each VM myself in VirtualBox and got those same problems with Guest Additions. It is usually caused by mismatched versions between it and the VirtualBox installation.
    1 point
  27. I personally love it for the modularity and interchangability of containers (and thus: features). So exchanging PHP to HHVM is an easy task. Vagrant is (imo) too "monolithic", but I think a little more easy to set up, especially with puphpet et al. Docker on the other hand can be quite cumbersome if you want your own containers, re-compile apps etc pp
    1 point
  28. +1 for the future compatibility between LivePreview and RepeaterMatrix. For me the two go together, the possibility to allow users to create longf-orm content and build pages by adding and reordering of blocks is a great combination of power and usability (in my mind). Thanks again for all the hard work Ryan!
    1 point
  29. You don't have to add strings exactly as the default language but keys too, eg. you can use __('text_message_1'). So you can add translation also for the default language in the admin.
    1 point
  30. Ok, i can confirm that ProcessWire does work on NGINX and HHVM (no traditional caching being used atm), normal page load times are around 1.5 seconds according to Chromes network inspector. Setup is as follows: install NGINX as normal, and HHVM from hhvm.com I've edited the /etc/hhvm/server.ini file to make HHVM run on port 9001 so i can run it along side PHP-FPM on port 9000 HHVM will create a hhvm.conf file in your NGINX directory. edit this conf to point hhvm's relevant port number. location ~ \.(hh|php)$ { fastcgi_keep_conn on; fastcgi_pass 127.0.0.1:9001; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } Then in your NGINX sites-available edit the file to route URLS to ?it= location / { try_files $uri $uri/ /index.php?it=$uri&$args; } Then include the hhvm.conf to handle the PHP processing. include hhvm.conf; Restart both HHVM and NGINX and it should be running just fine, with the option to switch back to PHP-FPM if needed. Hope this helps, setup seems to be pretty quick!
    1 point
  31. Nice guide if you want to develop on a physical server. A year ago or so I switched to developing on virtual servers set up with vagrant. They're a breeze to setup and you can carry them with you wherever you go. Recently I discovered protobox which makes it quite easy to setup virtual machines with preinstalled processwire, wordpress or whatever else.
    1 point
×
×
  • Create New...