Leaderboard
Popular Content
Showing content with the highest reputation on 12/22/2016 in all areas
-
Just stopping by to wish all the other members a happy Christmas. Or if you don't celebrate Christmas, then a happy holidays! And if you don't have a holiday, maybe you'll get one next year :-p Been working on two websites concurrently with PW so pretty busy! Not been able to stop by here as much as I would have liked. On a plus note, both are now at the demo stage. I actually need to find some work in the new year as I'm kicking off my self employment again, so anyone wants to see the demo sites to see the kind of stuff I'm doing, then I'm happy to share in a PM. TBH, they're not highly technical, still more brochure style at the moment, but looking to move onto bigger and better things. Maybe a meetup in Surrey or something would help kickstart things a little. Have a good one people Sam.4 points
-
There's really no difference between a 'filter' and a 'search'. The filter sidebar is a effectively a search form that submits automatically every time one of the form elements changes (the submit is executed with Javascript). The index page is effectively a search results page - when no filters are set the search is fully open. Using a variable for your $pages->find() selector string it would be something like: $selector = "template=hotel, limit=5"; In the index template you look for $input->get() variables. As an example, take a single GET variable: stars=4 You check that the variable name is valid (is one of the variable names you are expecting, otherwise ignore it). You sanitize the value appropriately for that variable (in this case it should be an integer). Then you add to your selector string accordingly, narrowing down the results your selector will return... $selector .= ", $approved_var=$sanitized_value"; You will probably build up your selector string by looping over all of $input->get(). You don't need a separate template for the filter form. If you want to use the filter on several templates you can put the code in a separate PHP file and include it in your templates. Check out the Skyscrapers profile for a good example of a search template: https://github.com/ryancramerdesign/skyscrapers2/blob/master/search.php https://github.com/ryancramerdesign/skyscrapers2/blob/master/_func.php4 points
-
depending on the amount of entries frontend filtering could also be an option: http://ohmspeaker.com/speaker-filter/?length=13&width=103 points
-
3 points
-
The problem is that PDO is outside the PW namespace, which is why the "\" is necessary to get you to the global namespace. That change definitely works for me. But then you'll get an error with the way you have your execute([$limit]); I would go with this version instead: function getKappers($limit = 10) { $rs = wire('database')->prepare("SELECT * FROM appointment_kapper WHERE (actief = '1') ORDER BY volgorde LIMIT :limit"); $rs->bindParam(':limit', $limit, \PDO::PARAM_INT); $rs->setFetchMode(\PDO::FETCH_ASSOC); $rs->execute(); return $rs->fetchAll(); } Note that I also used FETCH_ASSOC so you automatically get an array back without needing to iterate the results to build it up.2 points
-
Hi, Namespace issue? http://stackoverflow.com/questions/19699319/php-namespace-pdo-not-found use \PDO;2 points
-
2 points
-
If you're using ryan's MapMarker module (http://modules.processwire.com/modules/fieldtype-map-marker/) you can add the API key in the module config settings. If not, this page explains how to add it when you manually add the script: https://developers.google.com/maps/documentation/javascript/get-api-key <script async defer src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap" type="text/javascript"></script>2 points
-
Ahhh... new module name: ImportingMadeEasy! Absolutely great! I tested with field pairing and it works without any flaws. And no rush with the "Configurable Pages" issue, or even if it is no doable. The way BCE now works is absolutely great and I can plan to migrate a few websites to PW. Many thanks and have a great christmas holiday.2 points
-
2 points
-
Just wanted to add, that an image has also an width, height and description property. So you could output it like this: $thumbnail = $page->image->size(600,480); echo "<img class='entry-thumbnail' src='{$thumbnail->url}' width='{$thumbnail->width}' height='{$thumbnail->height}' alt='{$thumbnail->description}'>"; So you don't have to change the width and height attribute manually.2 points
-
For those wanting to delete source images, you can find my script in this Gist. Make sure you have successfully converted the images to the CI3 standard before you run it to delete the source images.2 points
-
This is not the right way to get the url of a single image. When using image fields you want to select the "Formatted value" setting that suits the number of images your field is allowed to hold. I recommend you stick to two of these options: Array of items - select this when "Maximum files allowed" is set to either 0 (no limit) or greater than 1 Single item - select this when "Maximum files allowed" is set to 1 Next you need to understand what is going to be returned when you use $page->image (assuming your image field is named 'image'). If you chose "single item" then $page->image will be a single image object. If you chose "array of items" then $page->image will be an array of image objects. You don't want to ever echo an object itself (it may return some value but it's generally not good practice), but you might echo some property of the object (e.g. description) or call some method on the object (e.g. url or size). When dealing with an array of image objects you will either loop over them with foreach or you can get a single object from the array with a method such as first() or eq(). So take this code example from above: You want to get the URL of a single image in the field. If your image field is formatted as "single item" then you would do this: $image = $page->image->url; If your image field is formatted as "array of items" then you would do this: $image = $page->image->first()->url; One more thing... You are setting width and height attributes on the img tag so you should use the size() method to make sure the image is cropped to the same dimensions (or same ratio of dimensions if you are wanting a HiDPI image). $page->image->size(600,480)->url Otherwise you wont get the desired result if someone uploads an image with a different aspect ratio.2 points
-
Here's a little Hanna Code snippet I wrote that allows you to insert a tag that contains any HTML element of your choice along with any attributes. The only defined Hanna Code variables are "element" and "comment". If you leave element empty, it will automatically use the "div" HTML element. The "comment" variable is optional and doesn't get outputted on the frontend. It is only for internal use and if you want to actually describe what the Hanna Code is doing. Import these two into Hanna Code: "tag" !HannaCode:tag:eyJuYW1lIjoidGFnIiwidHlwZSI6IjIiLCJjb2RlIjoiXC8qaGNfYXR0clxuZWxlbWVudD1cImRpdlwiXG5jb21tZW50PVwiXCJcbmhjX2F0dHIqXC9cbjw/cGhwXG5cL1wvaWYoIGVtcHR5KCRhdHRyW1wiZWxlbWVudFwiXSkgKSByZXR1cm47XG4kcmV0dXJuID0gJzwnLiRhdHRyW1wiZWxlbWVudFwiXTtcbmZvcmVhY2goJGF0dHIgYXMgJGsgPT4gJGEpIHtcbiAgICBpZiggJGsgPT0gXCJlbGVtZW50XCIgfHwgJGsgPT0gXCJjb21tZW50XCIgKSBjb250aW51ZTtcbiAgICBpZiggIWVtcHR5KCRhKSApICRyZXR1cm4gLj0gJyAnLiRrLic9XCInLiRhLidcIic7XG59XG4kcmV0dXJuIC49ICc+JztcbmVjaG8gJHJldHVybjsifQ==/!HannaCode "end-tag" !HannaCode:end-tag:eyJuYW1lIjoiZW5kLXRhZyIsInR5cGUiOiIyIiwiY29kZSI6IlwvKmhjX2F0dHJcbmVsZW1lbnQ9XCJkaXZcIlxuaGNfYXR0cipcL1xuPD9waHBcblwvXC9pZiggZW1wdHkoJGF0dHJbXCJlbGVtZW50XCJdKSApIHJldHVybjtcbiRyZXR1cm4gPSAnPFwvJy4kYXR0cltcImVsZW1lbnRcIl0uJz4nO1xuZWNobyAkcmV0dXJuOyJ9/!HannaCode Now for some examples: Example 1: Section [[tag element="section"]] will output... <section> Example 2: Section with class [[tag element="section" class="myclass myotherclass"]] will output... <section class="myclass myotherclass"> Example 3: Section with id [[tag element="section" id="myid"]] will output... <section id="myid"> Example 4: Section with inline styles [[tag element="section" style="color:red"]] will output... <section style="color:red"> Example 5: Section with any attributes you want (data attributes for instance) [[tag element="section" my-custom-attribute="test-value" data-something="cool"]] will output... <section my-custom-attribute="test-value" data-something="cool"> Example 6: Same as above with "element" not defined (defaults to "div") [[tag my-custom-attribute="test-value" data-something="cool"]] will output... <div my-custom-attribute="test-value" data-something="cool"> Example 7: Same as above with "comment" set (which does not get outputted) [[tag my-custom-attribute="test-value" data-something="cool" comment="Don't remove this line or your page will get totally messed up!"]] will output... <div my-custom-attribute="test-value" data-something="cool"> Example 8: Close section tag [[end-tag element="section"]] will output... </section> Example 9: Close div tag [[end-tag]] will output... </div> Example with a common Bootstrap rows and columns scenario: [[tag class="row"]] [[tag class="col-sm-6"]] This is the first col. [[end-tag comment="end of first col"]] [[tag class="col-sm-6"]] This is the first col. [[end-tag comment="end of second col"]] [[end-tag comment="end of row"]] -- Note the following article regarding the terms "element" and "tag": http://perfectionkills.com/tag-is-not-an-element-or-is-it/1 point
-
Oh! Silly me... I forgot that the $limit in the execute was still there... (that's what you get with C/P-ing) And of course yes, now the backslash is the solution. @adrian: correct, I should use FETCH_ASSOC (and maybe :limit too)1 point
-
Thanks @mel47 and @Klenkes - I have pushed that version to Github. Happy holidays to all!1 point
-
No...the older children. You will need to grab the first, e.g. into a variable, or their IDs then delete them.1 point
-
Excellent! Glad it worked and thanks for sharing the final solution. Similar to what Adrian was saying then (basically a new parent). @adrian, thanks for the ideas1 point
-
Here are is a SCSS snippet if you would like to use inline roles (I'm not liking those big green asm items). It also enables removing roles by clicking on its label (not only on its icon), "user" icon instead trash and there's a line-through effect on hover too. You can use an online tool to make CSS from it.1 point
-
Looks really sharp! I'll print a screenshot and put it under the Christmas tree One thing though. Doesn't cook coffee1 point
-
If you don't want a user role to change templates, just make sure to not give it page-template permissions.1 point
-
Just seeing @adrian answer. That's definitely it. I've run out of time so can't test further. See if Adrian's solution works. If not, hopefully others chime in, meanwhile. Quick btw: In the code where you delete child pages, no need to delete their repeater pages there as well. They will be automatically deleted when you delete the child pages.1 point
-
I've seen that too, hand in hand with a near doubling of new sessions in GA with arbitrary pages/view rate for last month, so this really messes up the stats. I've found some reports saying that these entries all come from Accept-Language headers (not Measurement Protocol) so it should be possible to block these requests at server level with a regex on Accept-Language that throws away anything that doesn't match the required format given in rfc7231. I'm going to take a look after Christmas hols if Akamai lets me add that such a filter in DSA. It should be relatively easy to do in Apache and NGINX, something like RewriteCond %{HTTP:Accept-Language} !^$|\*$|([a-z]{2,3}(-[a-z]{2,3})?)(\s*,\s*[a-z]{2,3}(-[a-z]{2,3})?)*($|;) [NC] RewriteRule ^.*$ "-" [F] The regex isn't a complete validity check and untested yet, but it should get the job done. Might even work for a GA filter too.1 point
-
Thanks for the suggestions everyone and @FrancisChung for the link. I eventually solved this the hard way by manually correcting all the foreign characters. As it was a live site and in use I didn't have the luxury of gradually eliminating each Module or a more methodical approach.1 point
-
I think the admin UI could be re-arranged into a table layout: first column: action names second column: description/notes third column: applied roles + and Edit button, that opens a modal or perhaps only unhides the role asmSelector. Alternatively you can set the asmSelect to operate in "inline" mode, I've experimented with that and it worked. I know it would take some time, but sooner or later this has to be done1 point
-
Getting a little OT here, but @Juergen - if this is incorporated into Admin Actions, you could call it via the API like this: $options = array( 'field' => 99, 'sourcePage' => 1131, 'destinationPage' => 1132 ); $modules->get("ProcessAdminActions")->CopyFieldContentToOtherPage($options); Yes, that action should be improved to also handle field names (not just IDs), but you get the idea.1 point
-
strip_tags is the simplest for sure. If you want more control, try the textarea sanitizer: https://github.com/processwire/processwire/blob/35df716082b779de0e53a3fcf7996403c49c9f8a/wire/core/Sanitizer.php#L10221 point
-
Media Manager version 009 (released 16/12/2016) Happy to announce the latest release of Media Manager. Changelog Filter Profiles: Feature enables configuring of various media filter interfaces (similar to ListerPro). This feature was requested here. Please see otes below Filter Profiles Usage To use the so-called Filter Profiles feature, you will first have to enable it in your settings (see images below). Head over to any media view. You will see a 'config' tab next to the Filters tab. Click on it. It will open a modal Create your profiles (one at a time). These are added to a table in that modal view. Click on the title of a filter profile to configure it's filters. Moves to 'single filter profile edit view' Set a filter as active by selecting it in the dropdown at the top of the modal view (#2) To delete one or more filter profiles, click their trash icon and save (there's a checkbox to confirm action) Close the modal. The Media Manager Library will reset and if you set an active filter in #5, your Media will be filtered according to your settings Currently, any user can create filters. Depending on your feedback, this might change. We might also add other features, e.g. locking down filters so they cannot be deleted. OK, that's it from Media Manager for this year. Hope it's been fun! Thanks.1 point
-
@SamC - please see ryan's response: https://github.com/processwire/processwire-issues/issues/96#issuecomment-264145798 Perhaps reply there if you want to discuss with him further.1 point