Leaderboard
Popular Content
Showing content with the highest reputation on 09/09/2018 in all areas
-
I've tested lightbox2 and it works fine. I am using the Initialize with HTML as per the docs. You don't have to call the script manually on the page unless you are passing options. You will need to set data-lightbox attribute to each <a> element. The following is based on a fresh PW install that uses the _main.php, _init.php, etc, approach, but it should work regardless of your templating approach. _main.php This is where we will output our markup. It is also where we include the CSS and JS for lightbox2 In this example, JS is included in <head>. Move it as you wish. Note the locations of the CSS and JS in this example. Your paths could be different. I uploaded the script's images to /site/templates/images/. This _main.php is the one found here in a ProcessWire install. <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates?>styles/lightbox.min.css" /> <script src="<?php echo $config->urls->templates?>scripts/lightbox-plus-jquery.min.js"></script> gallery.php I created a template file called gallery.php and a template called gallery. I then created a page that uses this template and uploaded some images. The images field in the template is called images. The contents of gallery.php are below. It is similar to the code in basic-page.php found in this ProcessWire install. If using a different template approach, you can just echo out the value of $gallery, for instance. <?php namespace ProcessWire; // gallery.php template file // Primary content is the page's images gallery $gallery = ''; // if there are images, lets choose them to create an image gallery if(count($page->images)) { $cnt = 1; // if the page has images grab 'em $images = $page->images; foreach ($images as $image) { // create/get image thumbs $thumb = $image->size(150,150); // add image to gallery $gallery .= // @note: unique data-lightbox value! (for single images according to docs) // link to full image "<a href='$image->url' data-lightbox='image-{$cnt}'>" . // image thumb "<img src='$thumb->url' alt='$image->description' /> </a>"; $cnt++; } } else { // no images... $gallery .= '<p>Sorry, there are no images in this gallery</p>'; } // append gallery and body markup $content = $gallery; $content .= $page->body; That's it! If you view the page, you should have a working gallery. Demo4 points
-
This module has just been made public under a MIT license. The opening post has been updated to reflect its release.3 points
-
Hi @kixe, I hadn't seen this before. I just had a quick look around and from what I can tell, it's a simpler version of @kongondo's RuntimeMarkup in that it doesn't allow you to use PHP to generate the markup. Would you mind describing the differences for us please?2 points
-
Hello All, I've been working on a new Fieldtype + Inputfield combination that handles street addresses. I've been using it now for about 3 months on my latest administration system for a charity and, so far, it seems to be working really well for them. It's based on the meta-data from Google's LibAddressInput project and uses the data feeds from that to build a cache of address formats used by various countries. My initial testing was aided by @Macrura and @adrian - and they were later joined by @mel47 and @BFD Calendar - so a big thank-you to them all. You can access the repository on GitHub and the Module Repository. Here's a few images from the project. First up: config screen. Here's an early version... ...and a more recent update... Here's a UK-based address. The module can integrate with my tag parser, if installed. Note that the output is formatted according to the output meta-data from the feed - which should match the preferred postal preferences of the destination country. Which subfields are required, and their regex expressions (if any) are also pulled from the feed and used as validation rules on the input side. Here's an address in the Netherlands - inputfield layout is currently adjusted on save - if you've configured it to adjust based on the destination country. Hopefully this will eventually be ajax driven. Use of the address preview is configurable and the HTML output can include micro-format data. Address sub-fields can also be used in selectors... Back with inputs, if you prefer a table-based input - you can have it... Format hints (unfortunately, I've found that many users need these)... Let me know if you find any issues or if you have any feature requests. So far, I have this from the previous testers... Allow multi-lingual address input for countries that support a multi-lingual postal system (like Canada.)1 point
-
Thanks Pwired! I will take a look at this. In fact I think I will build a new test install to see how it differs from Kongodo's work! ? Kongondo: thanks for catching that error. I would never have zoomed in on that issue. The good news is that the three test uploaded images now show as thumbs on the page! And when you click on one you get the Lightbox doing its thing. Yay! Progress!! But one issue: the image has this odd extra box strip on the right side of the image? And there is no previous/next navigation on the images? The other thing I am doing differently than your example is that I am linking to the latest jquery script directly (not linking to a file in my template folder) and I am not using the combined Lightbox and jquery lightbox-plus-jquery.min.js file. Instead I am using just the Lightbox.min.js file. Could this be a conflict or something? <edit: I tried the combined jquery file link and that does not change the result...>1 point
-
1 point
-
Thanks. I'll have a look. I agree. I checked already, almost 2 months ago ?. It's definitely the frontrunner for inspiration. Yep, keeping this in mind, thanks.1 point
-
I just committed a new version with several tweaks and fixes for the old, unloved Template Resources panel. It now better detects variables, constants, and functions that are only used once and therefore redundant code. The panel icon is now also colored to warn you that there are redundant things that you could remove.1 point
-
Could be interesting if you can integrate this as an option: https://omnipay.thephpleague.com/ because it has several implementations for gateways by the community: https://omnipay.thephpleague.com/gateways/community/ and can be extended easily... It will be perfect if you can check the backend of Shopify (14 days free trial), is really easy to use and understand for the customers. The workflow concepts and the organization of product information, collections, discounts, inventory, etc is very simple and concise, minimal enough for a regular store. My personal recommendation is to stay away from Magento like UI and concepts. Maybe the backend could use some ideas similar to your Media Manager or Visual Page Selector, I like the visual look and the user interaction.1 point
-
I didn't write the initial module - this is a port of a Drupal module. I did this for an agency who wrote the Drupal module and because they are now using PW for several sites, they wanted a PW version of this. It was their choice to use checkboxes. As you can tell they are set up to toggle automatically, but I agree it doesn't really make sense - users are used to radios toggling and checkboxes being for multiple selections. Maybe at some point I'll move this module to use radios, but we'll see ?1 point
-
So, food for thought in terms of REGEX vs DOMDocument: Benefits of using REGEX: Essentially faster/more efficient for processing of the data Doesn't care about valid source structure as it's parsing straight text, not XML nodes Implementation is unlikely to change Detriments of REGEX: Writing a perfect implementation of a REGEX when dealing with HTML to handle all use-cases without experiencing any edge-cases is difficult (might "greedily" match more than intended) It definitely works, but the developer argument is: is it the best (most appropriate) tool for the job? Without a good knowledge of REGEX, harder to understand the underlying code if changes/updates are required Benefits of using DOMDocument: Written specifically for the purposes of this type of task (searching/modifying the DOM) DOMDocument shouldn't ever be "greedy" over what it matches, like REGEX unintentionally tends to do Detriments of DOMDocument: May require valid HTML, but with iterations of HTML, what exactly is considered valid? Would different versions of PHP handle the DOM differently with version differences? Potential of implementation changes. loadHTML() may modify your source - what goes in might not be what comes out Character encodings may cause unforeseen issues (don't they always!) Without a good knowledge of PHP's approach to using DOMDocument, the code process can get rather difficult to understand if changes/updates are required Some further reading from someone else with more thorough testing: https://blog.futtta.be/2014/05/01/php-html-parsing-performance-shootout-regex-vs-dom/ https://blog.futtta.be/2014/04/17/some-html-dom-parsing-gotchas-in-phps-domdocument/ Realistically it's a judgment call. Speed and server efficiency versus (one would hope) better valid modifications/detections. I don't think there's really a right or wrong solution. Some shared hosting servers don't install the DOMDocument PHP extension by default though, so you'd want to check for the existence of the function during your module's install method. P.S. - Thanks for asking the question -- I knew DOMDocument was slower, but haven't compared in awhile. The articles I saw above were an interesting read. ?1 point
-
Busy morning ? Firstly, a huge thank you to Steve (@netcarver) for his epic rework of the Diagnostics panel - take a look at the diff https://github.com/adrianbj/TracyDebugger/pull/24/commits/8604a683ef408b4106f7b7237b3eae6c24de315a - he's put in a huge amount of time on this. I have merged his changes and bumped up Tracy's version to 4.11.0 - it deserves a major point bump for this ? If you haven't used this panel much in the past, you really should take another look and give it a thorough go - it's really useful for new and experienced devs alike! I also also added @tpr's blue for the icon color. Not sure about the inverted scheme just yet - any strong thoughts on it? I do think that the background color of the bar (the light version) could be made to look a little less dirty though. BTW, as a reference, take a look at the default Tracy bar: https://nette.github.io/tracy/tracy-debug-bar.html - be sure to check out the panels as well - we have @tpr to thank for our version looking considerably better than that ? Regarding the automatic dumping of both full object and debugInfo versions, it could be as simple as this - just one version, and then the other. Perhaps some visual indicator so you know it's from one call or something. Any ideas/thoughts? @szabesz - you mentioned wanting the page ID shown without having to open the object - I don't think is any simple approach to do that, especially given that not all dumped objects are pages. Of course you can do: d($page, $page->id) but that's only useful if you are dumping multiple pages at once so you know which one is which. If you have any more specific thoughts on how to implement what you are looking, let me know. Regarding the memory limit error - not sure what can be can about that - I guess Tracy can't handle that error because the error broke Tracy ? Seriously though there is just so much output when you have all panels toggled on that it's not surprising that these come up occasionally - I haven't seen one, but I up the PHP memory limit on my dev machine to 128M. Hopefully I answered everyone's questions, and please don't forget to test the new Diagnostics panel and give @netcarver your feedback.1 point
-
I've just issued a PR to the main repo for a reworked diagnostics panel for Tracy. This... Adds a "Dedicated" server switch via cookies. Adds colour coded cells. Displays file permission flags. Adds checks for existence, ownership, readability by process user, writability by process user, world-accessibility, execute/traversal. Detects installation of the PW Upgrade module. Detects use of non-file session handling. Adds basic checks of the debug, chmodFile and chmodDir config settings. Unifies the colour scheme with the new Tracy constants. Supplies formatted suggestions for chown, chgrp and chmod commands (on non-Windows servers.) Adjusts severity of issues reported based on Local vs Production server and/or Dedicated vs Shared server. Adds links to documentation for some assets. If you want to try it out and let me know any problems you find, please consider using my temporary Fork of Tracy on github until Adrian has had a chance to consider merging the PR.1 point
-
Thanks for all your answers!!! This was really fast and seems like a very active community! I'm sure the code snippet by @szabesz and the fieldtype by @kixe will work as well and are definitely more lightweight. I went with the RuntimeMarkup fieldtype suggested by @elabx as it was the fastest and easiest one to apply. Here is my php snippet for the runtime field: return " <a id='custom-action-button' href='#' onclick='copyUrlToClipboard(event);'>Copy URL to clipboard</a> <input type='text' value='" . $page->httpUrl() . "' id='target-page-url'> <p id='action-executed-hint'>Successfully copied URL to clipboard!</p> <style> #custom-action-button { color: #FFF; background: #93BF0D; font-weight: bold; padding: 0.6em 1.1em; font-size: 1em !important; border-radius: 5px; } #custom-action-button:hover { color: #FFF; background-color: #DB1174; } #custom-action-button:active { color: #FFF; background-color: #860A47; } #custom-action-button:visited { color: #FFF; } #target-page-url { position: absolute; left: -9999px; top: -9999px; opacity: 0; pointer-events: none; } #action-executed-hint { display: none; } #action-executed-hint.show { display: inline; } </style> <script> function copyUrlToClipboard(event) { event.preventDefault(); var urlText = document.getElementById('target-page-url'); urlText.select(); document.execCommand('copy'); var hint = document.getElementById('action-executed-hint'); hint.className += ' show'; } </script> "; It creates an a-tag which is styled like a backend button. Hope its useful for someone else!1 point
-
Sounds to me like a good option is the RuntimeMarkup module, so you can basically render whatever you want in the inputfield, and add the necessary javascript to do the whole copy-paste to clipboard.1 point