Leaderboard
Popular Content
Showing content with the highest reputation on 06/12/2016 in all areas
-
I just wanted to share this library here: http://barbajs.org/ It's a pjax implementations specifically for handling page transitions without full page-reload as simple as possible. It's super lightweight and can literally be installed by pulling the library in, adding two classes to your pages and a single line to initialize the whole thing. I've just added this to my personal site (https://kobrakai.de/) and beyond some js refactorings – mostly so that animations are not only triggered on page loads – it was a very smooth experience to add. Also I've probably only scratched the surface on this simple site. The docs look like this could handle even more complex setups if needed.9 points
-
Thank you Benjamin. It seems I often pick up very useful information from your posts. I wanted to say thank you also for this link you posted recently. http://adamwathan.me/refactoring-to-collections/ It's prompted me to put some time aside to do some self-study on functional programming done with PHP Here's just a few additional links I found should anyone else be interested - There seems to be a good amount of information out there on the subject. https://blog.liip.ch/archive/tag/functional-programming https://www.sitepoint.com/functional-programming-and-php/ Thanks again.6 points
-
For the time being it's fine to use 2.7.2 – that's our latest stable release after all – but if you're just now starting a new project, and especially if it's going to be under development for a while, I'd strongly suggest basing it on either 2.8 or 3.x devns. If you're feeling slightly adventurous and choose to go with 2.8 or 3.x, the choice between these two depends mainly on whether you plan to make use of external libraries etc. in your project. 3.x includes namespaces, 2.8 doesn't – other than that they're essentially the same and will remain so thanks to the fact that Ryan has mostly automated the process so that updates to 3.x also get applied to 2.8. While namespaces are cool for serious development and can make it a) easier to pull external libraries into ProcessWire or b) pull ProcessWire into other projects, in my experience most site projects don't benefit much from them. If the idea of namespaces makes you uncomfortable and/or you have no idea what they are, it's absolutely fine to go with 2.8. For the most part the built-in FileCompiler in 3.x hides namespaces from plain sight, but if you just want to build a regular site with ProcessWire and don't want to worry about all that namespace stuff at all, you'll probably feel more at home with the 2.x branch5 points
-
That was kind of funny, so I decided to share... Recently I faced the same problem once again and went to the forum search for the answer. How was I surprised to find this topic by myself with a solution by myself present! Of course I did not remember that I already asked that . So I decided to come here no more. Went to github, wrote an issue and got the fix from Ryan the same day in the latest release. The moral is if you find a problem and found the solution make sure it is fixed forever in the master code, so you don't have to deal with it ever again. And the way to do it with PW is using github (issues or even better PRs). All that sound obvious, but may be not so for someone like me thinking that devs read the forums all day long looking for some stuff to fix.4 points
-
For basic selectors this would have probably been enough. Though I'm not sure if it covers all edge-cases correctly. $isShown = $page->is($field->showIf);3 points
-
2 points
-
It a really strange move of a hoster to enable caching without explicit user-consent. Without knowledge of the applications running on their systems this is more or less expected to cause serious troubles. Also – this might be nitpicking – but it's not a bug in pw if the server's caching mechanism is returning outdated content.2 points
-
Hi everyone! With Batcher you can batch-edit and create Pages in the Pw Admin. If you install this module, you get a new Page "Batcher" under Setup. Modules page: http://modules.processwire.com/modules/process-batcher/ Github: https://github.com/wanze/ProcessBatcher Editing How does it work? Search your pages with a selector. You can check if you want to include also hidden/unpublished pages with the filters. Select the pages you want to execute an action (the action only gets executed on "checked" pages). Select the action and if necessary, additional data like the new parent or the new template. Execute. Supported actions: Publish/Unpublish Pages Hide/Unhide Pages Lock/Unlock Pages Trash Pages Delete Pages Change Parent Change Template Batcher does the following permission checkings for the current user: Don't display pages that are not editable Remove Actions if the user doesn't have the permissions (page-delete, page-move, page-template, page-lock) Important notes: When changing a template, data in fields of the old template which are not assigned to the new template gets deleted. When changing the parent, the template of the new parent must accept the pages template as children. This is a setting in the template under "family". Creating How does it work? Select a parent where your new pages will be added as children Add as many pages as you want by clicking "add Page" Click "Create Pages" You must enter a title and choose a template. The name is optional: If left empty, Pw will generate this for you. Includes permission checking and Family template restrictions. This means in detail: The selected parent must accept children and their template The pages template must accept the parents template User needs the permission to add children to the selected parents template User needs the permission to create Pages for the chosen Template Batch-creating tips The chosen template and the statuses are always cloned from the last row. So if you need to add 30 pages with the same template, define it first and the click "add Page" - it'll make your life easier ;-) You can drag & drop the table rows should you want to change the order. The dragging looks ugly but it works. For the lazy dogs and keybord hackers among us, you can add a new row by pressing "ctrl+n". This works (at least in firefox) only if no input has focus. After adding a new row, the title input gets the focus. By pressing 3 times tab you arrive at the published-checkbox, here the short-cut works. Restrict Batcher for a user to only allow editing or creating Create permissions "batcher-edit" and/or "batcher-add". As soon those exists, the module checks if the current user has the permissions. If you only need batch creating, check out the following module by Soma: http://processwire.com/talk/topic/2138-process-tools-create-pages-wip/ Cheers1 point
-
@horst Thanks for this module, I've been hammering it pretty hard for the past month and have just created a pull-request over on github for your consideration. I've been having a few reliability problems with the textfile driver's itemCount() method. I also wanted a fast way to purge a queue without having to call getItem() repeatedly. The itemCount() method sometimes returns an incorrect count (anywhere from 0 to the true number of items in the queue). This happens even when there are multiple thousands of jobs queued up and it makes it unreliable as part of a conditional statement. The explanation is given in the commit that fixes the issue as part of the pull request. Thanks for looking!1 point
-
Holy crap! It works the same, with no hand! Thank you LostKobraka, I thought selectors is not "selectors" in this case. I'm still not used to how PW requests all data from the page ... just with simple form of request. It's like a miracle, once again I convinced that. Thank you again!1 point
-
Hi @kixe - glad you're finding it useful. I have just added Exclude/Include switch that you suggested. The default is exclude to ensure backwards compatibility for those upgrading and not checking anything new in the settings. Thanks for the suggestion and please let me know if you have any problems. Also, I have now made the module always ignore the homepage - before I recommended users exclude it on multilanguage sites, but I couldn't think of any reason why it would be needed on any site, so I think this is simpler and cleaner.1 point
-
I've recently started having strange problems with ProcessWire on my host. Things not saving, not updating. Various other problems. The problems seemed to be due to caching, as if I saved the page, did a hard refresh, then visited the page I edited, did a hard refresh. It would work. Otherwise data would get corrupted. After questioning my hosting about Caching. They informed me that they have recently installed UNIXy Varnish to help with page load times. Great idea in concept, however it was quite confusing for me. Luckily there is a way to disable this in cPanel, however I would like to bring it to peoples attention as it's appearance does come across as a ProcessWire bug.1 point
-
Exactly my thoughts, as I mentioned, I fully understand it's not a bug. It was strange for me because I updated to 3.0.21 just about the time they rolled this out. I tried to crop images and it would corrupt the image. Naturally as I wasn't informed of this caching I thought it was a bug. This post is purely for people who may experience this in future. However, I think this maybe a rare case as you mentioned. I would full expect a host to inform me when changes are done like that.1 point
-
From a photographers or images redacteurs perspective I would say that the best presentation option would be a weightened one, based upon amount of pixels! see in the comparision image the first and second set of images: https://processwire.com/talk/topic/8367-pia-pageimage-assistant/#entry81648 This way, neither landscape- nor portrait- oriented images, nor square dimensioned ones become visually more present than the others.1 point
-
Echoing a comment above... In the image field 'list' view the size difference between landscape-format and portrait-format images can be extreme. In the screenshot below the two images have the same aspect ratio but the portrait-format is rendered much larger. Wouldn't it be better to define the thumbnail container as a square with the thumbnail centered and fitted to the container? Then each image row is an equal height.1 point
-
I just came across another issue with SessionHandlerDB - I am getting the following error with the latest Tracy dev core when trying to reopen a session. 1406 Data too long for column 'data' at row 1' in SessionHandlerDB/SessionHandlerDB.module:109 I will be looking into this further shortly, but just wondering if this might have something to do with the image upload as well. Maybe the data field simply needs to be changed to mediumtext or longtext, or maybe it's more complicated. I am definitely having some issues though too with the session being closed that only happens when SessionHandlerDB is installed.1 point
-
@Macrura May I suggest using WireData instead of StdClass. This makes code more resilient to missing properties and prevents lot's of isset() nonsense. $a = new \stdClass(); if($a->test) echo $a->test; // Will generate a PHP Notice "Undefined Property: …" $a = new WireData(); if($a->test) echo $a->test; // Does nothing; $a->test === null1 point
-
I just needed to fiddle around some more to find my answer. $image_fields = $fields->find("type=FieldtypeImage"); Looking at the data for a field I guess you can also find fields by id, flags, name and label. Nice!1 point
-
It's surely possible. Recently I've done a very similar newsletter solution, see screens here. Basically you need to send an email with contents of the newsletter page body (or other) field. Things get complex when you need things like preview email (which is a must imho), subscriber lists, etc. I've done this addons mainly with JS/Ajax.1 point
-
The redirection is probably the most problematic part of this plan, because the new page load will interrupt the visitor’s typing. What you would want to do is keep the search box and simply change the rest of the page using javascript. If the browser supports it, you can use history.pushState() to do manipulate the address bar, so visitors can have bookmarkable links to their search results. Here is a crude solution using jQuery. As you can see, JavaScript does most of the work: Normal page looks somewhat like this. There is a search box and some unrelated content. <body> <form id="searchform" method="GET"> <input type="text" name="s" value="purple unicorns" /> </form> <div id="content"> <!-- Your regular content stuff goes here. If the user starts typing, we replace all of this with a placeholder, do the search, then replace it with the results. Of course you would want to do something a bit more sophisticated and pretty in real life. --> </div> </body> Some JavaScript that runs on the above page and requires jQuery. $(document).ready(function() { $('#searchform :input').on('input', function() { $("#content").html('<h2>Loading…</h2>'); loadSearchResults(function(result) { if (result === false){ result = '<h2>An error occurred.</h2>'; } if (result == '') result = '<h2>No results found.</h2>'; $("#content").html(result); }); }); function loadSearchResults(callback) { var form = $('#searchform :input[value!=""]'); var serialized_form = form.serialize(); //if your search field is named “s” this will be “s=search words” if (serialized_form !== '') { var new_url = '/search/?'+serialized_form; //consequently, this will be „/search/?s=search words“ if (/* IE9 needs this check */ history.pushState) history.pushState({}, '', new_url); //your address bar now shows www.example.com/search/?s=search words $.ajax({ type: form.attr('method'), url: '/search/', data: serialized_form, success: function(result) { if (callback && typeof(callback) === 'function') { callback(result); } }, error: function() { if (callback && typeof(callback) === 'function') { callback(false); } } }); } } } The search page /search/ handles a GET parameter called s and either serves a full results page, or just the markup necessary to inject it into existing pages. <?php $s = $input->get->text('s'); $results = $pages->find("title%={$s}, limit=100"); $results_markup = "<h2>{$results->count} results found for “{$s}”:</h2>"; $results_markup .= "<ul>"; foreach($results as $r) { $results_markup .= "<li><a href='{$r->url}'>{$r->title}</a></li>"; } $results_markup .= "</ul>"; //if we’re live-searching, output only the results markup, //without <html>, <body> etc. if($config->ajax) { echo results_markup; return $this->halt(); } //now do your regular markup include('head.inc'); echo $results_markup; include('foot.inc'); ?> IRL you would probably serve JSON instead of full markup, but this keeps the JavaScript part short. You would also want to handle cases where users use the live search and then hit their browser’s back button.1 point
-
Hey gentlemen! I just happen to need this kind of js on a project of my own and am experiencing some trouble with implementing it. So please post the solution here if it is possible. Or just do not go private .1 point
-
Thank you - was my fault. While installing the module with modulesmanager I just found the options module. Daaaaaaaah hours for nothing . Great support! So People get both modules and watch the pw magic happen.1 point
-
Hey guys! Sorry, I'm not giving great attention to the module lately and I'm tight with time right now. @evan, your pull request seems reasonable, so I will accept it as is. Don't worry about the fix not being the most elegant. The module is naturally hacky in it's own nature already1 point
-
I've encountered this bug a number of times when launching, finally got around to looking into it and submitted a pull request. Not the most elegant fix, but it seems to work. My fork is available here: https://github.com/deeplypixelating/pw-admin-custom-pages1 point
-
Just some additions to teppo's point 1 / 4 (mvc and routing): In my current big project I'm using a hybrid strategy, where simple sites just use the default "file per template" – even though we have a dump router in the beginning to allow for different folders based on the rootParent – and for more complex pages / page-structures I'm using FastRoute in those template-file to route different urlSegments to a controller class. This way I don't need to roll a controller class for each and every tiny page, but still have the option to fall back to such a class if the need for more structure is there.1 point
-
Well that's the main thing, figuring out a system that integrates well into PW and is simple enough. See the images below of my current newsletter page in the admin and the final outcome. There's a dedicated Newsletters page in the root page tree, newsletters are listed below them. This is useful because newsletters have their own URLs so "View in browser" is easy to implement. The subscribers have another page in the root, each subscriber is a page. They can be active or inactive, based on the page status published or not. I use simpe subscription, no confirmation emails. I do not use subscriber lists, this should be also implemented somehow. I use wireMail() for sending (with MailGun), but queing would be also nice. It would be nicer to have a new nav item in the admin "Newsletter", and move the newsletters and subscribers there. Anyway, this is what I've got, maybe these can generate some ideas.1 point
-
So great updates, many thanks for this work! A little cosmetic thing: The size of portrait images In list mode are very large and blurry even with the smallest possible slider setting. Could be confusing for customers. Maybe limiting the longest side of an (portrait) image to a maximum to render it smaller but sharper? Besides that the proportions / sizes of portrait and landscape images are more homogenous to each other. EDIT: Oh, 2 minutes after sending this I found the checkbox "There are older/low quality thumbnail preview images above – check this box to re-create them." So the blurring is gone... sorry. Only the size for portrait images seem too big (for my eyes) – especially if you shrink the viewport – after the break they take a lot of space.1 point
-
Basically as soon as I can. This is something that I would love to use myself, so I am eager to get it finished for various personal projects. I could have finished this by now if it was for my personal use, as I would have cut corners here and there, but I want to release it as a module that everyone can use. This is a part time project for me as I'm not a PHP programmer, so I often don't know what I'm doing. But I have the ideas and a vision, so I will crack on and hope others comment on my code in order to improve it. As a prime example, do you personally like the idea of being able to choose your own module for the comments / replies? I could hard code it into the core module as I did previously with HermodBB, but if other modules exist to fit the bill, then why invent the wheel? But that's just my opinion. PW gives us so much flexibility, and that's what I want to take advantage of. PW takes care of users, permissions, profiles, and that's the beauty of it as it's something I don't need to bother with.1 point
-
Thanks for the hint in the right direction, after a few hours of searching I finally found the right syntax somewhere in the forum. I couldn't find this specific call anywhere in the documentation on FrontEndUser? This is how I logged in my user after a successfull login: // Login after succesfull registration $fu->addHookAfter('save', function($event) { $user = $event->object->form->fhValue('username','text'); $pass = $event->object->form->fhValue('password','text'); $this->session->login($user, $pass); });1 point
-
Hi! Just currently using this on our proof of concept and on a hackaton. It's like ServicePage module but the difference is it return data without the need of extra programming (Image field for example). Also it only coded on the template. It primary used template URL segment to identify what page should be returned. All output is generated in JSON format. You can view it here.1 point
-
$pages->find("template=x, pagearrayfield=1234"); // where 1234 is the page ID // this will also work $wanted_page = $pages->get(1234); $pages->find("template=x, pagearrayfield=$wanted_page");1 point