Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/04/2016 in all areas

  1. Most of this week and ProcessWire 3.0.10 has been focused on covering issue reports and related tweaks/fixes, which you'll see in the commit log. But we've also got a major upgrade to the core in 3.0.10 as well, with the introduction of ImageMagick and a new module type: ImageSizerEngine– http://processwire.com/blog/posts/processwire-3.0.10-expands-image-resize-options/
    7 points
  2. For resizing an image the whole image needs to be loaded into memory (at least for gd lib, which is used by processwire until now), therefore it's expectable to hit a limit of 3MB/s when needing to read a file of more than three times that size. Even on a dedicated server there can be speed or memory issues with this kind of image sizes. So you either need to think about if shared hosting is the correct environment or if you could limit down the size of the images to be processed. The latter option could be manual or automatic client side shrinkage of too big images. If you still need the original images you'd want to store them in a file field instead of an image field. This will prevent that thumbs are generated from the big image. Yesterday ryan did push an update to the pw 3.0 branch, which added the possibility to use other image processing libraries than gd, which might be more catered to processing big images efficiently, but depending on the shared hosting these might not be available.
    4 points
  3. I suggest to read https://www.littlebizzy.com/blog/ttfb-meaningless, and especially look for TTLB (Time To Last Byte). IMO, TTFB is completly meaningless,the only thingthat matters is: how fast can a user read / see the content of a page. And if you read on Wikipedia TTFB_vs_Load_Time or the more in depth article why it is meaningless, you may see that this doesn't matter. One thing, what is described there for example, is, that if you use gzip compression for your html / js / css content, you get a higher TTFB, but the TTLB is 20-30% lower! But besides that, using ProCache is the fastest way to serve your content. It also includes a part that assist you to setup the server for gzip, caching etc, it can collect and minify your JS, CSS, and HTML files, and you completly ommit invoking the PHP engine and connecting to a DB.
    4 points
  4. Just wanted to post here to note that the issue @planmacher had has been fixed - it was actually affecting the role name and custom php code options.
    3 points
  5. $pages->find($selector, array('returnVerbose' => false, 'loadPages' => false));
    3 points
  6. hi citech, i would recommend to create a separate template + page for that directly in the PW pagetree! if you put your file directly in the root you may run into problems some day (eg if you want to do a profile export). it's very easy to setup, although it is also a LITTLE more work: create a template (contact) + template file (eg /site/templates/contact.php) create a page in PW pagetree (eg /tools/contact) no you can point your form submit to /tools/contact and you have everything well organised and in place. you should try to keep all your own work/changes in the site-folder. this method does also have the benefit that you have all the PW api available (like sanitization which you will have to do with your contact data) and can also use urlsegments and all the great pw stuff welcome and have fun with PW edit: use caution what settings you use for "trailing slashes" or you may point your form to a 301 redirect. it can make a difference if you use /tools/contact or /tools/contact/
    3 points
  7. i think some of the usecases can be solved by using normal pages and using https://processwire.com/talk/topic/11040-visual-page-selector-commercial-page-picker-module-for-processwire/ for selecting them on other pages
    2 points
  8. I've been using DigitalOcean for about 3 years now. The upsides are: - cheap - they charge by the hour, so you can create and destroy droplets all you want (for testing/learning) without incurring large fees. - lots of tutorials if you're interested in learning how to do a lot of stuff - 99% uptime for real. Never experienced any downtime in 3 years. - freedom! Since it's an unmanaged VPS, you get to choose exactly what's in it. Downsides: - fixed plans. You can't customize your VPS specs outside of the preconfigured ones. - you have to do everything yourself. If you're new to unmanaged VPS's, it will take a lot of trial and error to get things just right. All in all, it was a great experience. I highly recommend it specially if you like learning about how to manage your own VPS. Also, try to look into AjentiV. It's a very cool VPS manager that I promote just because I think it's awesome and it's free, just like Processwire. <3
    2 points
  9. Move all section template files in a folder "sections" and include them like that for rendering in other templates: $markup = wireRenderFile("sections/section-article", array( 'page' => $pageToRenderOf )); Because the files are no longer stored at the default template path these pages do no longer show up as viewable.
    2 points
  10. 3 years PWired, but PW still surprises. Right marriage.
    2 points
  11. A "getIds" option might be nice. $pages->find($selector, array('getIds' => true)); It would be in a similar vane to: $pages->getByPath('/path/to/page', array('getID' => true)); but would obviously return an array of IDs, rather than a single one like with getByPath. Or maybe: $pages->getIds($selector); which has the same feel as: $pages->count($selector);
    2 points
  12. ProcessWire doesn't dictate any of the frontend code at all - you can write whatever HTML, CSS, and Javascript you want and simply add in the content from the PW database wherever you need. So, the answer is definitely yes, but you still may want to take the content from the landing page and make that editable by the Processwire backend, although this certainly isn't necessary. If it's the homepage of the site, then you will be putting the HTML they provide into: /site/templates/home.php - if there is no need for any php or calls for field data from the PW database, you can leave off the opening php tag completely. Hope that helps.
    2 points
  13. (https://en.wikipedia.org/wiki/Time_To_First_Byte) ProCache does serve static HTML files! PS: TTFB is meaningless
    2 points
  14. just a small thing: i think it would be good to turn the option "follow this topic" ON by default. i know you can do this in your settings, but i think for new users this can be really hard to find - especially if they don't even know about it i think this kind of opt-out would make more sense and would prevent new users from missing answeres to their questions (for example if they think their question is already answered but then someone comes whith a new hint and they never read it because they never check back to this topic...)
    1 point
  15. Thanks a lot adrain for the solution and the additional information, it works just perfect! This system is just great, especially the community! Thanks again!
    1 point
  16. Another approach would be a hook in your init.php $this->addHookAfter('Page::viewable', function($event) { if(strpos($event->object->template, 'section-') !== false) { $event->return = false; } });
    1 point
  17. I've been wondering that for a long while now too! I also just write everything mobile first, then add the tablet-up styles. It is a great framework and so quick and easy to use!
    1 point
  18. That's not going to work like that. First of all $pages is not pageFinder, $pages->pageFinder() is. Also the first argument is typehinted to Selectors, so putting a string won't work as well. That's why I've not mentioned it as I find it more confusing to use instead of the simple "add those options". If there would be a companion function in the Pages class it would be nice. $pages->pageFinder()->findIDs(new Selectors($selector));
    1 point
  19. PageFinder has a findIDs() method that sets the returnVerbose attribute. It doesn't set loadPages attribute, but I presume when returnVerbose is off it automatically does not return pages. Untested, but this should work: (Oops. Doesn't work. See below.) $pages->findIDs($selector);
    1 point
  20. The returnVerbose is something I found in the PageFinder class. Not sure how much it's needed.
    1 point
  21. WireMailBranding Add email templates to wireMail From this: $mail->bodyHTML("<h1>Hello</h1><p>I'm WireMailBranding</p>"); To this: (or whatever template you create) How it works? Create an email template without content. On the spot where you wish to have your content place the tag {bodyHTML}.The markup you've set with $mail->bodyHTML('<p>Markup</p>'); will replace that tag. You could set the defaults in the Module configuration or set the properties with the API. (See below) The API will overwrite the default settings $mail = wireMail(); $mail->to('user@some-domain.ext')->from('you@own-domain.ext'); $mail->subject('Mail Subject'); // Set path to template (overwrites default settings) $mail->template('/site/templates/template_wrapper.php'); // Enable/Overwrite the Emogrifier CSS inliner. (0, bodyHTML, wrapper) $mail->inlineCSS('bodyHTML'); $mail->bodyHTML('<p>This paragraph will replace the {bodyHTML} tag in the mail template.</p>'); $mail->send(); CSS inliner We have added the beautiful css inliner Emogrifier to inline the CSS styles. When using the Emogrifier CSS inliner applying it on the bodyHTML only is the most efficient way. We recommend you to write the inline styles for the wrapper manually. The module is sponsored by Calago.nl. Thanks guys ! Updates 0.1.2 Bug fixes : - Fixed redeclare Emogrifier bug. Improvement - Added error logging for Emogrifier - Added inputfield error for the lack of PHP's mbstring in the module configuration. - Some code cleaning and other cosmetics 0.1.3 Bug fixes : - Fixed bug when module couldn't grab bodyHTML (resulted in doing nothing at all). GitHub https://github.com/Da-Fecto/WireMailBranding Modules directory http://modules.processwire.com/modules/wire-mail-branding/
    1 point
  22. You could use the custom attribute options argument for radios, checkboxes etc in the addOption(). $field->addOption($key, $value, array("class" => "customEmoClass")); The rest is CSS and or JS. So you could do it like this. The label can be empty, and the $value would be the attr array. $evaluationVals = array( 'sehr_befriedigend' => array("title" => "sehr befriedigend", "class" => "smily1"), 'befriedigend' => array("title" => " befriedigend", "class" => "smily2"), 'mittelmaessig_befriedigend' => array("title" => "mittelmässig befriedigend", "class" => "smily3"), 'unbefriedigend' => array("title" => "unbefriedigend", "class" => "smily4"), ); foreach ($evaluationVals as $key => $value) { $field->addOption($key, "", $value); }
    1 point
  23. The longer answer: yes, a hook should work, but you'll have to modify the html output of InputfieldRadios::render. Quick&Dirty: /* site/ready.php */ wire()->addHookAfter('InputfieldRadios::render', null, 'addOptionImages'); function addOptionImages($event) { $obj = $event->object; if($obj->name == "NameOfYourRadiosField") { $opts = $obj->getOptions(); $ret = $event->return; foreach($opts as $key => $value) { $id = $obj->id . "_" . wire('sanitizer')->name($key); $ret = preg_replace( "~(<input.*?id='{$id}'.*?)<span.*?>.*?</span>~", '$1' . "<img style='display: inline;' src='$value'>", $ret ); } $event->return = $ret; } } The "display: inline" style is needed to keep the image on the same line as the radio button.
    1 point
  24. The solution is here: https://processwire.com/talk/topic/12375-urgent-will-pay-help-debugging-image-fields/
    1 point
  25. The solution is here: https://processwire.com/talk/topic/12375-urgent-will-pay-help-debugging-image-fields/
    1 point
  26. For those of you who haven't seen it: https://github.com/buunguyen/octotree - it's a great extension for navigating projects. There are versions for Chrome, Firefox, Opera and Safari.
    1 point
  27. After upgrading the ProcessWire installation to 2.7.2 the methods next() and prev() work like they should.
    1 point
  28. OMG. How many users will upload images to this site? Multiple / different users, or only you? I personally use max size = 2500px for the largest dimension of an (original) image. I create those with Photoshop in max quality before uploading.
    1 point
  29. Using bourbon-neat in two current projects, and kinda like it. But I don't really get why it isn't mobile-first by default - I know it's easy to adjust to be mobile first, but the official docs is using desktop-first approach. Does someone know the reason?
    1 point
  30. Glad to hear it's working for you - hopefully this new approach will work in all scenarios. As for debugging debug.innerHTML - I haven't had to debug it yet - it's mostly generated by Tracy anyway. Being a JS variable, there isn't really an easy way of making it multiline without concatenation, which really isn't worth the trouble in this case. I am looking forward to Template Literals in ES6 though - we'll finally have real multiline variables for JS. But, back to your question, - if you do need to debug code like that you can use the regex find & replace option in your editor to replace \\n with \n and \\t with \t and it will be fully formatted. In Sublime Text (in case you use that), click the asterisk in the find and replace box - super easy!
    1 point
  31. Yes, it works for me, I had to clean the templates cache. One more thing: debug.innerHTML is "oneliner", with " \n\n" etc. How do you manage to debug that?
    1 point
  32. @matjazp - just letting you know that the latest version includes the fix for your problem. Could you please let me know if it works for you?
    1 point
  33. @Ovi_S, Could you please mark your other two threads solved, thanks. Maybe also decide which of your three forum handles you want to keep
    1 point
  34. Anything, which is dependent on the time should not be stored anywhere, as it's potentially invalid minutes later. Calculating these at runtime is easy, but for db selection you'd need to build a custom selector or completely switch to raw mysql queries.
    1 point
  35. Perhaps this module from kongondo will let you do what you need without need to add your own hooks: http://modules.processwire.com/modules/fieldtype-runtime-markup/
    1 point
  36. Hi and welcome. You can check this thread too : https://processwire.com/talk/topic/12094-jquery-functions-and-path/?hl=ajax A small snippet I use at this moment : <script type="text/javascript"> // PW dynamic js var <?php $jsConfig = $config->js(); $jsConfig['debug'] = $config->debug; $jsConfig['urls'] = array( 'current_url' => $page->url, 'root' => $config->urls->root, 'templates' => $config->urls->templates, ); ?> var config = <?php echo json_encode($jsConfig); ?>; </script> Assuming you put your file "contact_me.php" in the root folder, to call it from JS, you can write something like that : [...] $.ajax({ url: config.urls.root + "contact_me.php", [...]
    1 point
  37. You could check with your host to see if they are running mod_security. I just struck the same 404 problem when I use an include in my Hanna PHP code. My host lets me disable mod_security via htaccess, and sure enough when I disable it the 404 problem is gone.
    1 point
  38. Just found a Suhosin setting that will definitely interfere with PW files fields: Note that 64 as the default setting for "max length" of variable names in POST requests. This appears to be ON by default with this value in Suhosin. That's going to cause issues all over the place in PW. If you have a files field with a name more than 18 characters, or any files field in a repeater, then Suhosin is going to block any data in it. It looks to me like Suhosin's default settings will potentially interfere with most of PW's multi-value inputs, not to mention some of Suhosin's other default rules will interfere with other parts of PW (and I'm guessing almost any powerful CMS other than perhaps WordPress).
    1 point
  39. How the class is written now it don't has access to WireMailSmtp, as WireMail is the parent class and not WireMailSmtp. To make it work with not known methods it needs a total rewrite, if even possible. But there's a work around. // This don't work with methods not know by WireMail $mail = wireMail(); // When you instantiate WireMailSmtp yourself it all works $mail = $modules->get('WireMailSmtp');
    1 point
  40. In my _main.php files I typically include a "layout" variation file. This is what you would start with as the main template, but moved outside to allow more customisation and flexibility. Specify a default layout to use in the _init.php file, and overwrite it in your template files as and when necessary. _main.php <html> <head> <style></style> ... </head> <body> <header class="header">...</header> <section class="main"><?php require "./includes/layouts/{$layout}.php"; ?></section> <footer class="footer">...</div> </body> </html> _init.php $layout = 'default'; // specify a layout that would be used for "most" pages (I call mine default) So most sites might have default, home and contact layout varieties as a starting point. A layout would include the stuff that varies between page designs and you would create as few or as many as you need, and call on the variables set by the template. For example, layouts/contact.php: <section class="content"> <p>This is our address</p> <?= $page->body ?> </section> <aside> <iframe class="map">...</iframe> </aside>
    1 point
  41. $g is an array of pages in your example that doesn't seem related to a particular page, so how does it know what next and prev are? Next and prev usually relate to the page being viewed, so $page->next() and $page->prev() should be all you need.
    1 point
  42. The problem is that you are choosing 6 from each category, and not 6 from all. The ideal would be to get all the portfolio pages with one selector. There are several ways of doing this, the one that looks more logical in your case is to select by template: $portfolio_pages = $pages->find("template=portfolio-item, limit=6, sort=random"); foreach($portfolio_pages as $item) { // echo here }
    1 point
  43. Yeah I think we probably should. Here they are. I've tried to tailor them for cheatsheet format and included an @advanced tag where applicable. I understand the sentences of text don't fit in the cheatsheet, so wasn't sure how you'd want to handle those (or leave them out), but put them here in case helpful. FieldtypeFile or FieldtypeImage can be configured to hold a single file or multiple files. When configured to hold multiple files, it is a WireArray (called Pagefiles or Pageimages) with these additions: <?php $files->path; // Returns the full server disk path where files are stored $files->url; // Returns the URL where files are stored $files->page; // Returns the $page that contains this set of files $files->delete($file); // Removes the file and deletes from disk when page is saved (alias of remove) $files->deleteAll(); // Removes all items and deletes them from disk when page is saved @advanced Each item in the WireArray is a $file or $image (called Pagefile or Pageimage). Likewise, when FieldtypeFile or FieldtypeImage is configured to hold a single file, it is just the $file or $image with the following properties and methods: $file properties <?php $file->url; // URL to the file on the server $file->filename; // full disk path to the file on the server $file->name; // Returns the filename without the path (basename) $file->description; // value of the file's description field (text). Note you can set this property directly. $file->ext; // file's extension (i.e. last 3 or so characters) $file->filesize; // file size, number of bytes $file->filesizeStr; // file size as a formatted string $file->pagefiles; // the $files array that contains this file @advanced $file->page; // the $page that contains this file @advanced (string) $file; // returns the file's name (no path) $file methods <?php $file->rename($name); // Rename this file to the given name (no path). Returns true on success, false on failure. $file->getNext(); // Returns the next file in a multi-file field, or NULL if at the end @advanced $file->getPrev(); // Returns the previous file in a multi-file field, or NULL if at the beginning @advanced When dealing an $image, it is the same as a $file, but with the following additions: $image properties (in addition to those in $file): <?php $image->width; // Width of image, in pixels $image->height; // Height of image, in pixels $image->original; // Reference to original $image, if this is a resized version. @advanced $image methods (in addition to those in $file): <?php $image->size($width, $height); // Return a new $image with the given dimensions (proportional, center crop) $image->width($width); // Return a new $image with the given width (proportional height, center crop) $image->height($height); // Return a new $image with the given height (proportional width, center crop) $image->getVariations(); // Returns a WireArray (Pageimages) of all size variations of this image. @advanced $image->removeVariations(); // Deletes all size variations of this image (be careful) @advanced
    1 point
×
×
  • Create New...