Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/01/2016 in all areas

  1. This week updates were focused on covering GitHub issue reports and feature requests, plus some great new performance improvements to our page traversal methods… https://processwire.com/blog/posts/pw-3.0.24/
    11 points
  2. @pwired This topic was moved to the dev section for exactly the reason of those tutorials not being about processwire. Also the thing is, as long as you don't understand php those fancy processwire snippets will always be a black box of magic and you won't be able to use them much more than for the exact use-case it was created for. Whereas with getting better at php you also start to see where those nice pw api abilities come from and how to use them on your own. It's not that black and white with learning things.
    6 points
  3. Hello folks I have updated the code in my rest helper. Since It was created nearly 2 years ago! Now its much easier to create rest endpoints in Processwire You can download the code here. https://github.com/NinjasCL/pw-rest This is and example simple login code. $response = new Response(); $params = Request::params(); if (!Request::isPost()) { $response->setError(MethodNotAllowed::error()); } else { $username = $params['username']; $password = $params['password']; if ((!isset($username) || $username == '') || (!isset($password) || $password == '')) { $response->setError(Login\Errors\InvalidCredentials::error()); } else { if ($username == 'hello' && $password == 'world') { $response->output['data']['name'] = 'Tony'; $response->output['data']['lastname'] = 'Stark'; $response->output['data']['job'] = 'Ironman'; } else { $response->setError(Login\Errors\InvalidCredentials::error()); } } } $response->render(); Will render something similar to { "data": { "name": "Tony", "lastname": "Stark", "job": "Ironman" } } Any questions or comments are welcome
    4 points
  4. Jeffrey Way, from the excellent Laracasts.com, just published a free series for PHP beginners: https://laracasts.com/series/php-for-beginners From the website: Jeffrey is a great teacher so if you are learning PHP, no better place you'll find.
    2 points
  5. You need to add the checkbox in the backoffice. Then you need to do some PHP stuff. It might seem fancy, but believe me it's quite easy once you'll get a hold of this hooking stuff. Create a ready.php in your /site/ folder. Then place this: <?php // You can hook into the saving process => https://processwire.com/api/hooks/ $pages->addHookAfter('saved', function($event) { // We grab the current object (the page being saved) and store it in $page $page = $event->object; // Only run this script on training templates if ($page->template !== 'training') return; // Only run this script on empty dates if (!empty($page->training_start)) return; // Save field hasdate_checkbox and set value to checked/1 $page->setAndSave('hasdate_checkbox', 1); }); Written in browser, so not tested. But following the links provided above you will get an idea.
    2 points
  6. Haven't used it now, but already like it! (have had a look to the readme!) Below an example of a root parent and a first level child:
    2 points
  7. Thanks for adding me as a colaborator, @horst. I've pushed a new dev branch to the repository that contains, Bugfixes to the textfile driver's itemCount() method and small cleanups for edge cases. New methods isEmpty(), purgeItems() and getItems() added to the base storage class and fully implemented in the textfile driver. The SQLite driver currently has stub implementations of these that need filling out. The addition of a Redis driver for super-fast in-memory queues (implements the full base class interface.) If anyone wants to give this a try before horst gets around to merging into the master branch, feel free to grab the zip (repository here.)
    2 points
  8. You have the whole API available to you for module development. The examples above are not specific to modules, but are methods of the Wire class. https://processwire.com/api/ref/wire/message/ https://processwire.com/api/ref/wire/error/ My go-to pages for module-specific info are: https://processwire.com/api/ref/module/ https://processwire.com/blog/posts/new-module-configuration-options/
    2 points
  9. I have been thinking about what would be the best option for core to handle the frontend variation image cropping. Would simply setting the focus point be enough? That would always be center when cropping (if not explicitly wanted something else). This would require zero configuration, wouldn't contain any design specific information (like image sizes) and would work for both horizontal and vertical images.
    2 points
  10. Thanks Ryan, I think you may well have hit the nail on the head with the Email Obfuscation module. I found that you can disable this on a template by template basis. Having disabled it for the thumbnails template and cleared the ProCache cache again, things seem to be OK at the moment. Obviously I'll have to keep an eye on it. The template is using URL segments - the page itself is /thumbnails/ and each moth family is an URL segment (crambidae etc.). This then pulls out just the thumbnails for species belonging to that family. The number of families is relatively static but can change. Probably I should set the $config->maxUrlSegments to 1 and then throw a 404 as you say for invalid values. Cheers!, Ian.
    1 point
  11. Bumping this old thread to shine some light on an obscure fact about that whitelist for domain names. Here's my story: Moved site from development server to real server. Some users (not all) reported View links sending them to the development server. Never happened to other users. Clearing browser cache did not help. Dumping DB and searching text for the development server domain name did not turn up anything. The only place I could find the development server domain name was in the config file in the array defining $config->httpHosts. Documentation calls $config->httpHosts a whitelist so I assumed I could put both the dev and real domain names in the list and maintain a single config file to use in both places. It's not just a whitelist!! The source code of ProcessWire.php explains that If you have not explicitly set $config->httpHost (note: no "s" on end) and the PHP vars for $_SERVER['SERVER_NAME'] and $_SERVER['HTTP_HOST'] don't match anything in $config->httpHosts (with "s") the getHttpHost function defaults to... "no valid host found, default to first in whitelist" The server's environment variables had the domain with www on it but the server accepts URLs with or without the www and people use either one. My dev site was the first one in the list.
    1 point
  12. Hey Marty, Unfortunately I never got around to finishing it - I just took a quick look at what I have and I think that rather than being a dedicated module, it might be better to convert it to an Action for ListerPro. I know that will obviously mean that you'll need a ListerPro license, but leveraging LP's ability to perform actions on just matched pages and its built-in batching will make for a more powerful and performant tool.
    1 point
  13. Try to replace the line $out = "\n<ul>"; with this one: $out = "\n<ul>\n\<li>\n\t\t<a href='{$rootPage->url}'>{$rootPage->title}</a>\n\t</li>"; (adding a class to the a element and modifying the \t tabs as needed).
    1 point
  14. Ian, first thing to check is how you are using URL segments. It looks like pages like http://ukmoths.org.uk/thumbnails/crambidae/ allow URL segments. If you don't need URL segments, disable them. If you do need them, then make sure you validate the URL segments that come in and throw a 404 if you get something invalid. For example: if(strlen($input->urlSegmentStr)) { // one or more URL segments are specified if($input->urlSegmentStr == 'photos') { // display photos } else { // invalid throw new Wire404Exception(); } } Second thing I would look at is the email obfuscation module you have installed. I notice the code it is adding (near the bottom of the source) appears to be using the same encoding that appears in those URLs, so I'm wondering if that might be adding it? Try uninstalling the email obfuscation module at least temporarily to see if it makes any difference.
    1 point
  15. hi, i also think that this would be a great addition but should NOT be the only option. playing around with the jquery demo (http://jonom.github.io/jquery-focuspoint/demos/helper/index.html) i see that it would lead to problems when you only want to show a small part of the image that is located near the border of the image. i think a more advanced concept like the imagefoucsarea plugin would be better. the best would be to have the good old cropping plugin with predefined ratios and/or dimensions, have a simple focus point option and even more have a more advanced focus-area option like in the plugin linked above
    1 point
  16. Since PW 3.0.21 (2.8.21) you can use: echo count($page->getLanguages()); in your case: if (count($page->getLanguages()) > 1) { $markup = ''; foreach($page->getLanguages() as $language) { if ($language->isCurrent()) continue; $markup .= "<li><a href='".$page->localUrl($language)."'>".$language->getLanguageValue($language, 'title')."</a></li>"; } echo "<ul>$markup</ul>"; }
    1 point
  17. Apparently the child has a higher z-index
    1 point
  18. Thanks @tpr - I have decided to remove that setMaxAllowedPacket method in the latest version - it's most likely not going to work for a standard SQL user on most shared hosts anyway. So, the message for everyone out there is if the debug bar isn't working and you have the PW core SessionHandlerDB module installed, you have three options: Uninstall SessionHandlerDB Increase your SQL max_allowed_packet setting (in your my.ini or my.cnf file, or via SET GLOBAL max_allowed_packet) - http://stackoverflow.com/a/5688506/1524576 Use the "Legacy" option for the Tracy core setting in the module config (not really recommended as you'll be missing out on core updates)
    1 point
  19. This is been resolved by the tech team that look after the servers. The issue was one of incorrect file permissions on assets/files.
    1 point
  20. Cropping for different devices shouldn't mean crop to smaller sizes by default. Say you have a photo with a group of people and one of that group is the subject. It wouldn't be weird to crop out only that person for smaller devices.
    1 point
  21. v018 is uploaded with the latest Latte version (2.4.0). There's an official way to set the default layout file so previous workarounds were removed.
    1 point
  22. Basically you have to create download pages under /downloads/, which is created by the plugin, for each file serving. You create them via the admin, or via API. Each /downloads/download/ page allows a file field and creates a unique hash, that you put, when invoking the file download, after the /downloads/hash/ url segment. Like for example /downloads/hash/18297192837oiu etc. Each download page allows for 5 file download, but you can customize the number. You can also customize the expiring time in the plugin settings. Be sure to tweak the plugin code as I mentioned in the post above, at least for me it solved a recurring bug.
    1 point
  23. I think that is a novel way of setting the focus point! But I don't necessarily agree that it should be the only option. I have feeling more novice users/editors would be confused by it not being "specific" enough, as they might not be able to visualise how that appears in the front-end on their news article for example. Unless the pre-defined crop areas - as they exist now - will still show a preview step, somehow? Perhaps I've been thrown by the multiple tiles in the demo? I just really enjoy how, for me and the projects I've worked on, CroppableImage has been one of the best image-related things in PW. It just helps so much being able to specify the dimensions images should be
    1 point
  24. It is an interesting option. Only thing that I may think of what is not good, is that it ever takes full width or full height of the original image. There are use cases where one want crop out a part. But for many other cases this seems a good solution. If I understand the concept right, there would be less hassle with lots of variations. Right?
    1 point
  25. Hi everyone! Thanks to a tip from Ryan, I now have the latest version of the Tracy core working properly when the core SessionHandlerDB module is installed. This means that I have been able to consolidate the number of packaged versions down to two: Legacy and Master. Now the only reason not to use Master is if you are running PHP < 5.4.4 I will keep the Master version updated with changes to core after testing to make sure there are no issues. The module now automatically adjusts your MySQL max_allowed_packet setting so that it is large enough to handle storing the Tracy debug bar data when you have SessionHandlerDB installed. Ryan has changed the "data" field in the "sessions" database table from text to mediumtext and says he'll be adding this to the upgrade routine shortly, but if you have problems with the Master version, please make this change yourself. Please let me know if you have any problems with the new Master version.
    1 point
  26. @saml: Have a look at the documentation. It's listed as an option and a basic example is available as well.
    1 point
  27. @Juergen, obviously I missed your post half a year New Edition But finally I found it and redesigned the template file I provided in post 88 of another thread It is working now properly according to the google guidelines. It comes with 301 redirect to the path version that lacks the language segment which works in PW 3.0 up but not in 2.7. In this case you need to uncomment the code line which forces the redirect. Template detects if the translation is checked 'active'. Furthermore you can easily adjust selectors for the page array where the pathes are taken from. Feel free to try and use it. multilang-sitemap-xml.php.zip
    1 point
  28. I'm working on a simple fieldtype module and trying to understand the wakeupValue, sleepValue and sanitizeValue methods a bit better. This and this have been helpful but I still have a few questions. My module is for storing a reference to an image that is contained in one of the image fields in a page. I'm using a customised select inputfield to choose from the available images, and the reference to the image is stored in the database as a string in the form: field_name|image_name In the wakeupValue method I convert the reference string to an image object. public function ___wakeupValue(Page $page, Field $field, $value) { list($field_name, $image_name) = explode("|", $value); $image = $page->$field_name->get("name=$image_name"); return $image; } This is working fine, but at the moment I'm not doing anything in the sanitizeValue method. To get an idea of when sanitizeValue is called I have this... public function sanitizeValue(Page $page, Field $field, $value) { $type = gettype($value); $log = wire("log"); $log->save("debug", "Sanitized: $value, Type: $type"); return $value; } ...and it shows that for every Edit Page save in admin the sanitizeValue method receives both the image reference string and the image object. Sanitized: photoxpress_8083749.jpg, Type: object Sanitized: images_two|photoxpress_8083749.jpg, Type: string Why does sanitizeValue get both these types? I can understand why the image object goes through sanitizeValue because I am setting that to the page, but why does the string go through sanitizeValue? I'm not setting the string to the page, just saving it to the database. For modules like this that store data in a different type than they send to the page, will the sanitizeValue method always need to account for both variable types? That is, the method can't expect $value to always be a string or always an object - it will need to test the type of $value and apply different sanitizing checks accordingly? And is this true for sleepValue also? Ryan said in another post: That makes sense if I was saving to my field via the API and set an image object to the field - sleepValue needs to convert the object to a reference string for storage in the database. But at the moment I'm only saving to the field via the admin, and so the $value received by sleepValue is a string coming from the inputfield, not an object. So to cover both bases I will need to test for the type of $value at the start of the sleepValue method? I guess I'm asking if this is the normal/right way for such a module to work or if there is some better way to set it up so that sanitizeValue and sleepValue only have to handle one variable type.
    1 point
  29. Hi @Gazley, There is no denying, Semantic UI is very beautiful. However UI Kit has a few more modules that lets me get work out of the door quicker (and make a bigger profit). Here are a few things that I really really like about UI Kit and some things that I don't. Grid 1. data-uk-grid-margin This will add a top margin based on the grid margin when the column is collapsed. This means on mobile no elements are sitting right on top of each other. Instead they have a nice margin between each section. 2. data-uk-grid-match Great for having columns in which you want equal heights, you can do some pretty nice visual designs with this. Such as 50%/50% full width layouts. Components 1. Parallax Like most things with UI Kit it's completely modular and I only include elements I want to use, this makes it super easy. Parallax is one of those elements, it means I can easily add in Parallax elements and still keep it all in the UI Kit Framework. Other useful components include... 2. Dynamic Grid Much like Isotope js, this allows you to create dynamic filterable grids. 3. Sliders There is many options here, there is Slider which allows for mouse scroll and is great for mobile. Slideset which is filterable, great for showing things like clients and Slideshow which is just your usual slider. This comes with plenty of animations, which is all also modular. Core 1. Flex components While not completely supported by older browsers, this gives great control over positioning of content, such as centering content in a div. Combine this with data-uk-grid-match and .uk-flex-middle, you can create absolutely beautiful looking sites. 2. Text Columns Responsive text columns are great, while they are relatively new in not widely supported in browsers, it's great you have that option for modern browsers. 3. Scrollspy Great for the elements that animate on scroll, you can add any class to this also (or even use the javascript event) to have full controls. Javascript Events You can easily hook into Ui Kits javascript events to add custom javascript when certain things happen when using the modules. I know most frameworks have this, but it's a nice things to have. Here is a CodePen showing off a few things that I mentioned (I've tried to put in as many as possible): http://codepen.io/anon/pen/dYVRgQ --- The Bad So here is the bad, not all the components are well polished and require little fixed. For example sliders (used in my example), I much prefer showing them 1 by 1 as it's nice for iPhone uses to use touch controls. However, if there is less than 4 elements, there is sometimes a white flicker on the previous slide as you slide through. It's subtle but it happens. I get around this by making the background black to the slider. It isn't a fix but it makes it less noticeable. The sticky menu doesn't play nicely with the offCanvas and will sometimes stick, I use CSS to get around this applying left: auto !important. Resizing the screen while offCanvas is open will not recalculate the width, breaking the responsive. I got around this by applying width: 100% !important; to the offCanvas overlay. One more thing is that it doesn't apply box-sizing: border-box globally by default, while this isn't much of a problem and more of a personal preference. Overall, these problems are being ironed out and github is getting more active. I do wish for the github community to grow as there are plenty of talented coders out there and UI Kit for me is a great framework which comes with many useful features and most importantly is modular to keep sites lightweight.
    1 point
  30. I just coded this functionality with updated methods of PW. I use it to give all the images of the news page as a package for press release purposes. This is triggered by a button on the page like below, so the link above does not change, page is stable but download starts. <button onclick="window.location.href='<?= $page->httpUrl; ?>?download=images'"> if ($input->get->download == 'images') { if ($page->images->count() > 0) { //collect images $imagesArray = []; foreach ($page->images as $img) { $imagesArray[] = $img->filename; } //zip images //TODO: in a function $zipPath = $config->paths->files . $page->id . DIRECTORY_SEPARATOR . $page->name . '.zip'; wireZipFile($zipPath, $imagesArray, [ 'overwrite' => true ]); $options = array( // boolean: halt program execution after file send 'exit' => true, // boolean|null: whether file should force download (null=let content-type header decide) 'forceDownload' => true, // string: filename you want the download to show on the user's computer, or blank to use existing. 'downloadFilename' => $page->name . '.zip' ); wireSendFile($zipPath, $options); exit; } }
    1 point
  31. Hey Pete - nice one! I know your code is meant as a quick snippet to get the job done, so no offense intended, but the concerns I have with this is: On a site with a LOT of pages, that could be very slow. I don't like the fact that it re-saves every page, regardless of whether there is a change or not, which will affect the modified date and modified user. I have actually already made a start on a feature rich search and replace module which I will get around to finishing up sometime soon. It provides the ability for searching and then showing the search term in context for each match. You can then choose which matches get replaced, or replace all. Stay tuned!
    1 point
  32. I think you can do this with the PIM module https://processwire.com/talk/topic/4264-release-page-image-manipulator/ The method you are looking for is canvas() Having said that, I would probably do it with css if it is ok for you using a css background-image instead of a normal <img/>. You can position and scale background-images easily with css like this: <style> .slide { background-position: 50% 50%; background-size: contain; background-repeat: no-repeat; } </style> <div class="slides"> <div class="slide" style="background-image: url(img.jpg)">Content Slide 1</div> <div class="slide" style="background-image: url(img.jpg)">Content Slide 2</div> </div>
    1 point
×
×
  • Create New...