Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/16/2015 in all areas

  1. Maybe this helps you. I'm using it in one of our sites for the exact same thing (you'll have to adjust the table names and get the coordinates of the given zip, though). The SQL Query uses the Haversine formula ( http://www.plumislandmedia.net/mysql/haversine-mysql-nearest-loc/ ) to find coordinates within the given radius. /** * Retrieves a list of address records residing within the given $radius of the given geo location * * @param float $lat * @param float $lng * @param int $radius * @return array */ private function proximitySearch($lat, $lng, $radius = 20) { $sql = <<<SQL SELECT * FROM ( SELECT *, ( ( 2 * 6378.2 ) * ATAN2( ( SQRT( POW( SIN( ( ( $lat * PI() / 180 ) - ( lat * PI() / 180 ) ) / 2 ), 2 ) + COS( lat * PI() / 180 ) * COS( $lat * PI() / 180 ) * POW( SIN( ( ( $lng - lng ) * PI() / 180 ) / 2 ), 2 ) ) ), ( SQRT( 1 - ( POW( SIN( ( ( $lat * PI() / 180 ) - ( lat * PI() / 180 ) ) / 2 ), 2 ) + COS( lat * PI() / 180 ) * COS( $lat * PI() / 180 ) * POW( SIN( ( ( $lng - lng ) * PI() / 180 ) / 2 ), 2 ) ) ) ) ) ) AS distance FROM field_address_team ORDER BY distance ) AS distributordistance WHERE distance <= $radius; SQL; $result = wire('db')->query($sql); if(!function_exists('mysqli_fetch_all')) { $retVal = []; while ($row = $result->fetch_assoc()) { $retVal[] = $row; } } else { $retVal = $result->fetch_all(MYSQLI_ASSOC); } return $retVal; } Usage (in this specific example the radius is extended by the factor 3 until at least 3 locations are found or the radius has been extended 3 times which would be 540km [(((20*3)*3)*3)] with default radius settings ): public function getTeamsInRadius() { $teamsArr = new \PageArray(); $searchCount = 0; while (count($teamsArr) < 3 && $searchCount <= 3 ) { try { // extend search radius by factor 3 as long as result set counts less than 3 hits // $teams = $this->proximitySearch($this->latitude, $this->longitude, $this->radius * pow(3, $searchCount)); foreach( $teams as $team ) { $teamsArr->append( wire('pages')->get($team['pages_id']) ); } $searchCount++; } catch (\Exception $e) { break; } } return $teamsArr; } A good idea when using this is to cache the results (see this blog entry for examples) for each entered ZIP until new entries are added to the database as the SQL Queries are pretty performance intensive. The benefit of this method is: You don't have to query Google Maps (or another GeoService) every time you're searching for locations.
    6 points
  2. Hi, I have first time used and setup OPcache for a site and found a useful explanation of some aspects / setting params here: fine-tune-your-opcache-configuration-to-avoid-caching-suprises Maybe it is useful for someone else too.
    4 points
  3. Plyr Media Player for ProcessWire ! beta status. This module is "work in progress" v0.2 ! Please be patient as this is my very first public module ^^ This module adds the Plyr HTML5 Media Player (plyr.io) to ProcessWire. Plyr is basically a wrapper for the natural media interface in modern browsers. It adds the ability for easy styling via CSS and a sprite, while being fully responsive. Also Plyr gives you full controll over the player with its great javascript interface. MarkupPlyrMediaPlayer incorporates Plyr for ProcessWire. -> GitHub -> Module directory Current capabilities After installation, you will notice some module configuration options. These are: - Automatic Mode If enabled, this option will automaticaly add all needed resources into your pages output. - Use CDN Use the official Plyr CDN (Content Delivery Network) for resources? The following resource options are only required if you don't wish to use the CDN: - Path to CSS file (Path to your CSS file, required to style the players.) - Path to Plyr library (Path to the Plyr javascript library, required for the functionality.) - Path to SVG sprite (Path to your SVG sprite image file, required to style the players.) Automatic mode If automatic mode is enabled, the module hooks after the page rendering and automatically adds the stylesheet to HTML head. Also adds an AJAX call to fetch the SVG sprite and the Plyr javascript library right before the ending body-tag. Also, while in automatic mode, that extra markup will only be rendered if a template made a render request for a Plyr player. So there will be no unnecessary load on your site. Get module $plyr = $modules->get("MarkupPlyrMediaPlayer"); Add a video player to your template echo $plyr->renderVideoPlayer($poster, $mp4, $webm, $captions); The $captions-Array contains details of the caption tracks: $captions = $caption = array(); $caption['label'] # Something like "English captions" $caption['src'] # http://...movie_captions_en.vtt $caption['srclang'] # en|de|ru|... $caption['default'] # true|false array_push($captions, $caption); Add an audio player to your template echo $plyr->renderAudioPlayer($mp3Path, $oggPath); Add the YouTube-wrapper to your template echo $plyr->renderYoutubePlayer($videoId); Manual mode If automatic mode is disabled, you have to render these parts manualy in your page template. Important: This method will not check if a player was requested. In the HTML head: <html> <head> ... <?php echo $plyr->renderHeadLink(); // Basicly just a <link rel="stylesheet" href="..."> ?> </head> ... And in the footer somewhere before the closing body-tag: ... echo $plyr->renderScripts; // AJAX call for SVG and JS library inclusion </body> </html> Where is this going? Before getting a v1.0.0 stable release, this module should be capable of following features: - [done] Load resources from CDN or local files - Reliable automatic mode with fallback to local - Brings specific Inputfields for video, audio and youtube for the backend and frontend markup rendering - Every Plyr javascript setting can be handled via module configuration
    3 points
  4. Welcome to the forums Tom! All kudos to Soma for the cheatsheet. Best thing since sliced bread More detailed examples are a little slower in happening but some of the items do have examples, not all. Shift and Pop are like their PHP array equivalents - shift gets the first item from the array, pop the last, and essentially removes it from the array for use right now. So your example would be something like: // Shift the first item off the beginning of the array to use right now. It's no longer in the array for this instance of the page $featured = $page->gallery->shift(); echo $featured->size(800,550)->url; // Get the footer item now for use later on - we don't want to iterate over it when displaying the other images just below: $footer = $page->gallery->pop(); // Now do some funky gallery stuff - this instance of the gallery array no longer contains the first and last items it did earlier foreach ($page->gallery as $item) { echo $item->size(400,400)->url; } // And now we can echo the footer echo $footer->size(800,550)->url; That should work, though typed into the browser and untested - let us know how you get on P.S. It is also perfectly acceptable to create two new single-image fields for featured and footer - might keep things neater in the admin for you - but this was an interesting request to explain some less-used functionality I think so I went with it
    2 points
  5. FrontendUser is based on the PW form api and PW inputfields. Haven't links here, but just search the forum. https://processwire.com/talk/topic/9467-add-a-css-class-to-an-inputfield-on-render/ https://processwire.com/talk/topic/2089-create-simple-forms-using-api/ I hope that will help you to style your form. If someone build a base / example style I'll add it to the module / documentation.
    2 points
  6. Hey Tom, Thanks. I've been using a similar looking theme I built locally for a long time, and I forget sometimes that it doesn't ship with the Reno Theme. What I will probably do is release the theme I have in a manner similar to the way @nico did with his LightWire theme. Actually, I may just see if Nico would release an additional color scheme for LightWire — no sense duplicating effort.
    2 points
  7. Not only does that article use weird terminology (popular interpretation of adaptive web design is something entirely different), but it's also missing important parts of responsive web design – including the whole point of doing web design in a device-agnostic way. In most cases I'd rather suggest looking into ways of improving your responsive design workflow with mobile-first approach, lazy-loading assets, etc. Either way, if you really need to go with server-side device detection, you might want to look into Mobile Detect module. It's far from a complete solution in this regard, but one step closer to what you're looking for
    2 points
  8. A new project, we are working on at updateAG, is now online (at least first step, online "reservation" process isn't yet) http://www.walder.ch The data for the shoes are imported from their system va CSV. They then can edit and publish and categorize them as they wish. Soon there will come a reservation process, that's only half implemented yet. It's an ongoing process in all parts and will get reworked or extended by time. They were using Typo3 before and were positively surprized and happy with ProcessWire and think it's all a lot simpler. They can edit all their content only with a rough 15 min crash course "showing" them ProcessWire. Design and concept is from another partner firm, who also executes the print campaigns for the client. Maybe something special to mention: is that we fighted a lot with their product fotos. The plan was to use transparent png's and then so be able to color the background. This lead to a lot of problems with png's and GDlib in general. Plus they delivered the fotos as optimized png's 8bit... etc. Very long story short. With the excellent PIA (PageImageManipulator by horst) and after lot of researching and testing I was finally able to "color a canvas", smash the png on it and have a jpg coming out on the other end! This way, we solved a lot of problems with a simple command and have regained back a lot of flexiblity, lesser artifacts and 10times lesser file sizes at the end.
    2 points
  9. This looks beautiful I've been using WordPress for quite a while, but I can't escape the fact that it's a blogging system over a CMS. I work at an agency and we publish WordPress sites all the time. We now have a network of about 40 of them and trying to keep them up to date is a daunting task. I've used other systems to try and move them away from WordPress such as Concrete5 and while that was better and easier for development, it was trickier for the clients with the drag and drop interface. Where I work we all fell in love with Craft CMS but found it far to expensive for our clients. ProcessWire seems like the perfect solution and I'm currently in the process of getting my head around everything, I love the API. It's always really encouraging to see websites as beautiful and as crafted as this, it really gives me encouragement and a goal to what I want to achieve. The best thing I've found about ProcessWire is things like Guess CMS have no idea what CMS you are running, and I imagine bots too. That seems super secure to me!
    2 points
  10. Ok, let's make it really simple for people using chrome to do this If you are using chrome do this to have PW search with google on the omnibox by simply typing "pw [spacebar]" 1. right click on the omnibox and chose "Edit Search Engines" 2. scroll down until you find these input fields 3. Fill them as in the image: third field should be https://www.google.com/search?q=site:processwire.com%2Ftalk++-site:processwire.com%2Ftalk%2Fmembers%2F+-site:processwire.com%2Ftalk%2Fuser%2F+%s This is the equivalent to this search in Google: "site:processwire.com/talk -site:processwire.com/talk/members/ -site:processwire.com/talk/user/ %s" where %s is the query 4. type "pw [spacebar] Edit Search Engines" and see if this thread appears in first PS: I'm sure there is an equivalent way to do this in other browsers, but I'm not going to look for that now. Edit: simplified the url
    1 point
  11. You need an extra ) before the continue. If you count 3 ('s there should also be 3 )'s
    1 point
  12. you have some options... <?php // version using PageArray(); $kids = $pages->find("template=poi, has_parent=$page"); $interests = new PageArray(); foreach ($kids as $k) $interests->import($k->interests); echo '<ul>'; foreach ($interests as $i) { echo "<li><a href='interest/$i->name'>$i->title</a></li>"; } echo '</ul>'; // or find all interests, cycle through but ignore those that don't apply to this page $interests = $pages->find("template=interest"); echo '<ul>'; foreach ($interests as $i) { if(!count($pages->find("template=poi, has_parent=$page, interests=$i"))) continue; echo "<li><a href='interest/$i->name'>$i->title</a></li>"; } echo '</ul>'; ?> wow, 3 replies!
    1 point
  13. You could filter them out in a temporary array...e.g. //example code $interests = $pages->find('template=poi, interests!=""'); //method 1 foreach ($interests as $int) { foreach ($int->interests as $p) {//interests is a multi page field; PW returns them as objects $array1[$p->id] = $p->title;//overwrite duplicate ids in the array key } } //method 2 foreach ($interests as $int) { foreach ($int->interests as $p) { if(in_array($p->id, $array2)) continue;//if we already have that id, skip it $array2[] = $p->id; } } //testing echo '<pre>'; print_r($array1); echo '</pre>'; echo count($array1); echo '<hr>'; echo '<pre>'; print_r($array2); echo '</pre>'; echo count($array2); Above are just examples. You could even store objects in the arrays, or create a temporary WireArray and store them in there. WireArray and PageArray docs: http://processwire.com/api/arrays/ Btw, the above code will not do the counting you want. That's easily doable as well... Edit: Reading your question again, this is probably not what you want...Oh well, code stays though..
    1 point
  14. Next little tutorial on this really great module... Getting a Footermenu stripped from the mainmenu and output in a footermenu 1. Setup Pagefield for your /settings/ or /tools/ page This solution could be set by the user direct via a simple pagefield to select normal contentpages that a normaly in the mainmenu...but this items should stay not there and render somewhere else... 2. Strip the choosen pages from the mainmenu //get the pagefield content $footerMenu = $settings->footer_menu; //just the needed option listed - other options like needed for your menu $options = array( 'selector' => 'id!='.$footerMenu.'', // define custom PW selector ); 3. Output the pagefield items <?php //in my example i am in the _main.php template and render some footermenu if ($settings->footer_menu) { //check for the pagefield echo '<div class="eight columns">'; foreach ($settings->footer_menu as $item) { if (!$item->is('hidden') || $item->is('unpublished')) { //check for hidden/unpublished pages!! echo '<a href="'.$item->url.'" class="button sendbtn btnSend">'.$item->title.'</a>'; } } echo '</div>'; } ?> hope this is helpful...have fun. I don't have a blog and i am a fan of keeping things together....so don't bother if i'm posting such things here and write me if such usecases are not helpful or nonsense...... Best regards mr-fan
    1 point
  15. Update to Version 1.1.3 (dev) Download from github https://github.com/kixe/FieldtypeSelectExtOption/tree/dev Changes hook in Inputfield render() replaced by adding magic toString() method to SelectExtOption class (which helped teppo and dsdb) @Teppo Thanks! filter() method is now hookable to define more complex SQL WHERE clauses. whole usage description available in module settings. from now all column values are populated as a property if the column is not named by a reserved word. Reserved words are: 'value','label','row' and 'data'. $page->myfield->value $page->myfield->label $page->myfield->row // associative array of all values of the selected datatablerow $page->myfield->columnname-1 $page->myfield->columnname-2 // ... I tested the Module with PW 2.6.17. Please give me feedback if the module works in your surroundings.
    1 point
  16. I think he is talking about delivering different ressources (and propably markup) depending on the device that is accessing the application. Have a look at: http://www.smashingmagazine.com/2013/10/responsive-website-design-with-ress/
    1 point
  17. Sure, somehow I imagined the topmost pages to not have parents anymore xD But the feature is still the right call. The page inputfield is calling Page::getMarkup, which you can simply hook. In the field settings just use insert "MySpecialLabelKey" or whatever string you want to init the hook. $wire->addHookBefore("Page::getMarkup", function($event){ $page = $event->object; $key = $event->arguments(0); if($key == "MySpecialLabelKey"){ if($page->template == "manufacturer") $key = "{title}"; if($page->template == "model") $key = "{parent.title} {title}"; } $event->arguments(0, $key); });
    1 point
  18. Maybe Teppo's article can help: http://www.flamingruby.com/blog/taking-apart-a-simple-textformatter-module/ It's from 2013 but it still is all valid i think.
    1 point
  19. Thanks. I completely take your advice. At the moment I'm just showing some content for myself while I develop a new part of a page so this will work great.
    1 point
  20. On mobile. You can use wire('log')->save('debug', $yourVar); Or var_dump(...); And/or die(); Or chromephp logger.
    1 point
  21. in your sites config.php you can set them like below. $config->imageSizerOptions = array( 'upscaling' => true, // upscale if necessary to reach target size? 'cropping' => true, // crop if necessary to reach target size? 'autoRotation' => true, // automatically correct orientation? 'sharpening' => 'none', // sharpening: none | soft | medium | strong 'quality' => 100, // quality: 1-100 where higher is better but bigger 'hidpiQuality' => 60, // Same as above quality setting, but specific to hidpi images 'defaultGamma' => -1, // defaultGamma: 0.5 to 4.0 or -1 to disable gamma correction (default=2.0) );
    1 point
  22. I plan to get this module up on github and add it to the modules directoy. In the meantime use my instructions and download above.
    1 point
  23. I am also looking for this as a fieldtype, because I have a Repeater field for different products with ratings. Also I want to integrate this with the comments fieldtype. How would I do that? I found https://processwire.com/talk/topic/10107-fieldtypestarrating/ as an alternative, which is a fieldtype, but it doesn´t handle floats (average ratings) and has no option to use the star rating on the frontend (rating and saving to database).
    1 point
  24. German language files for PW dev are now on new/other repo: https://github.com/Manfred62/pw-lang-de-dev. Only updated or additional files in this repo. Install the german language pack for PW master. Then add/replace with the dev files.
    1 point
  25. Thank guys for this module - it was great to quickly set up a ratings system. A couple of thoughts though. I am not sure why it needs to be an autoload module - I'd rather you simply load it manually in a template file when you want to use it. I am not sure why it isn't simply a custom fieldtype that can be added to templates as needed - the way you have done it seems to work just fine, but the one issue I am having is that it can't be used as easily in all situations - for example, you can't select "rating" as an option when configuring a custom view with ListerPro. I am sure there are also other situations where it would be preferable to be a fieldtype, but maybe there are advantages to the approach you have taken that I am not thinking about. Of course if #2 is implemented, then #1 is no longer an issue Any chance you'd consider a bit of a rewrite to make it a fieldtype? if not, please let me know and I'll put something together myself - just trying to avoid duplicate modules that do the same thing Thanks for considering.
    1 point
  26. What I use in front end from is doing my own validation when needed, some fields are already validated like password inputfield or email inputfield. On a register form I have something like this for example, combined with jquery validation for client side validation... if($input->post->register) { // processes form, validates and add error messages to fields $regform->processInput($input->post); // check email unique if any if($sanitizer->email($regform->get("email")->value) != '') { if(!$helper->isUniqueUserEmail($regform->get("email")->value)){ $regform->email->error(__("Diese E-mail wird bereits verwendet.")); } } // check username format only a-z0-9-_. $username = $sanitizer->pageName($input->post->username, Sanitizer::translate); if($username != $input->post->username){ $input->post->username = ''; $regform->username->error(__('Benutzername ist nicht im richtigen Format.')); } // check if username ($user->name) unique if(!$helper->isUniqueUsername($username)){ $regform->username->error(__("Dieser Benutzername wird bereits verwendet.")); } if(!count($regform->getErrors())){ ... I have helper functions like isUniqueUsername etc, that is at the same time used in jquery validation via ajax. Depending on your knowledge and how fluent you are with PHP and PW, I find it easy to add my own methods or checks where needed and found use of any external validation class not needed (was using that before).
    1 point
  27. I had the need of iterating through a lot (and I mean A LOT) of pages by template, and was also having memory problems. With this amount of pages it was becoming really annoying to do it few at a time, so I came up with a solution that doesn't need a wireArray. With this I could iterate over more than 50.000 pages with the same template on a website with more than 100.000 pages by bootstrapping PW from the command line. I just had to set a time bigger limit to PHP with set_time_limit(), and everything went fine and without interruptions. while (1) { $p = wire('pages')->get("template=my_template, id>$id"); // get page with id bigger than previous if(!$id = $p->id) break; // assign current page's id to $id or break the loop if it doesn't exist // do stuff using $p as the current page wire('pages')->uncacheAll(); // clean the memory (with $p->uncache() doesn't work. why?) }; edit: actually, using the command line I don't think set_time_limit() is even needed.
    1 point
  28. The prefered, simpler way is to make the user when created via API unpublished: $user->addStatus(Page::statusUnpublished); See cheatsheet addStatus Then the user can't login yet. And the admin can just go and publish the user (same as with pages) in the admin. Users are pages so the page API applies here same way as it is for pages. Or using API to publish $user->removeStatus(Page::statusUnpublished); See cheatsheet removeStatus The different system flags are also on the cheatsheet.
    1 point
×
×
  • Create New...