Leaderboard
Popular Content
Showing content with the highest reputation on 06/08/2013 in all areas
-
Yep, never underestimate this sponge's absorbing power2 points
-
I think I have done just that I've been using Foundation for a while now and really am amazed at how well it flows. There are a total of 13 template pages: banded, bannerhome, blog, contact, feed, grid, marketing, orbithome, realty, sidebar, soboxy, store, workspace. I was able to add those to a default ProcessWire install. I've been on these forums for months, really just taking my sweet time reading as much as I can about How-To-Do-This and How-To-Do-That. I have yet to actually use PW on a project site. I swapped out all the placehold.it tags and replaced them with holder.js https://github.com/imsky/holder I'd like to share what I have but I really just wanna do a few more things with it before I do.2 points
-
2 points
-
@pwired, there isn't any software that keeps compatibility with old versions of modules forever. That's why I think it's great that you don't have to use lots of third party modules with ProcessWire, and everyone should be aware of the risk of making a website completely dependent of them. Anyway, no one is forced to upgrade immediately to a latest version (or even at all), and Ryan shows he is always very concerned about breaking things for people, so I'm pretty sure that when it comes the time when that step really has to be taken, all modules (or a good alternative to them) will be already compatible. One thing I think it's important to keep in mind here is that software has to evolve. And this evolution will always be a balance between backwards compatibility and new and better features. You really don't want to use a software that stopped in time...2 points
-
You can detect whether the current page was loaded from ajax by checking the value of $config->ajax from your template file: <?php if($config->ajax) { // page was requested from ajax } Following that, you will likely want to render the page differently to accommodate whatever you are doing from the javascript side. For instance, you might want do one of these: 1. Deliver alternate or reduced markup when loaded from ajax 2. Deliver a JSON or XML string for parsing from javascript Below are examples of each of these scenarios. 1. Deliver alternate or reduced markup when loaded from ajax You might find checking for ajax helpful when you want portions of pages to load in your site without re-rendering the entire page for each request. As a simple example, we'll use the default ProcessWire site and make it repopulate it's #bodycopy area when you click a page in the top navigation. (To use this example, you'll need the default ProcessWire site templates, though you can easily adapt the example to another situation.) To accomplish this, we'll update our main page template to only include the header and footer markup if the page is NOT being loaded from ajax: /site/templates/page.php <?php if(!$config->ajax) include("./head.inc"); echo $page->body; if(!$config->ajax) include("./foot.inc"); Next we'll update the top navigation to do ajax loads of the pages when the client has javascript (and leave as-is when they don't). Paste this javascript snippet before the closing </head> tag in the header markup file: /site/templates/head.inc: <script type="text/javascript"> $(document).ready(function() { $("#topnav a").click(function() { $("#topnav a.on").removeClass('on'); // unhighlight selected nav item... $(this).addClass('on'); // ...and highlight new nav item $("#bodycopy").html("<p>Loading...</p>"); $.get($(this).attr('href'), function(data) { $("#bodycopy").html(data); }); return false; }); }); </script> Now when you click on any page in the top navigation, it pops into the bodycopy area without a page load visible from your browser. And all pages remain accessible from their URL as well. Note that this is just a test scenario, and I probably wouldn't use this approach for the entire bodycopy area on a production site (it would make bookmarking difficult). But this approach can be very useful in the right places. 2. Deliver a JSON or XML string for parsing from javascript Lets say that you want pages in your site to return a JSON string with the page's id, title, and number of children when it is requested from ajax. When not requested from ajax, they will return their content as normal. To handle the ajax requests, you'd want to add something like this at the top of your template file before any other output. <?php if($config->ajax) { // this is an ajax request, return basic page information in a JSON string $json = array( 'id' => $page->id, 'title' => $page->title, 'numChildren' => $page->numChildren ); echo json_encode($json); return; } // not ajax, continue with regular page output And here is some markup and inline javascript you might use to test the ajax call on some other page (or the same one if you prefer). You would paste this snippet right in your site's markup where you want that info to appear. <ul id='info'></ul> <script type='text/javascript'> var url = '/'; // this is homepage, so replace '/' with page URL you want to load JSON from $(document).ready(function() { $.getJSON(url, function(data) { $.each(data, function(key, value) { $("#info").append("<li>" + key + ": " + value + "</li>"); }); }); }); </script> The above snippet would output something like this: • id: 1 • title: Home • numChildren: 5 To take this example further, you could build an ajax-driven sitemap or any number of web services. Conclusion Hope this helps you to see how simple it is to use ProcessWire to deliver output for ajax. These are just contrived examples, but hopefully examples that might lead to more ideas. In addition, much of what you see in these examples is also applicable to building web services in ProcessWire.1 point
-
Local Audio Files - MP3-DB The Local Audio Files DB is a combination of a Module and a SiteProfile. It is intended to import MP3-files from your filesystem into ProcessWire, read ID3-Tags and pull coverImages from it to feed the DB. It is thought as a starting point for your own site creation. A sort of comfortable aggregated reuseable code for PW-lovers. How to Install Grab a copy of the latest ProcessWire. Replace the install, modules and templates directories with those in this profile, as shown below: /site-default/install/ /site-default/modules/ /site-default/templates/ With SiteProfile-Installs normally that is all there is to do. With this Profile you also have to copy the file LocalAudioFilesImportShellScript.php (for simplicity) to your PW-rootfolder, (where the index.php reside). If you are on Windows you also should copy mp3_import_starter4win.cmd to the same location. Now install ProcessWire as per the instructions included with it and it will install the LocalAudioFiles profile automatically. After that you find a Quickstart Guide at the homepage of the profile: Follow the 3 steps and you are done! How does it work? The Site has 4 sibling Tree Branches: genres - artists - albums - songs. Each of them hold child-pages: genre - artist - album - song. The logical relations are nested parent-children ones: a genre hold artists, each artist hold albums, each album hold songs. To support both, slim and fast data relations & the logical hirarchy, the module extends the ProcessWire variable $page with some additions. It uses the addHookProperty mechanism to achieve that. It uses an own caching mechanism for large lists, that can be prebuild when running the importer-shellscript, or it build the cache on demand. Also it comes with a FrontEndHandler class that provides a lot of functionality, for example fully customizable FormSelectFields of all genres, artists or albums. More detailed informations and code examples are collected in a demo section of the site. The extended $page variable together with the LocalAudioFiles-FrontEndHandler gives you comprehensive tools to work with your music collection. Download Modules Directory LocalAudioFiles-SiteProfile_v0.1.5.zip LiveDemo I have uploaded a small LiveDemo with only 7 truncated songs. But it's pretty fine to view all Demos and the additional $page->proterties. demo song page demo album page demo artist page demo genre page Graphical overview Screencast of installation https://youtu.be/-qYyppvEF1k History of origins http://processwire.com/talk/topic/3322-how-to-setup-relations-for-a-mp3-db-with-pw/ http://processwire.com/talk/topic/3462-pages-get-return-nullpage-but-page-exists/1 point
-
Did some digging about css frameworks in google. Found some links that might be usefull to read. 2 good articles about css frameworks http://coding.smashingmagazine.com/2007/09/21/css-frameworks-css-reset-design-from-scratch/ http://www.gridsystemgenerator.com/ do it yourself css layout http://designshack.net/articles/css/rolling-your-own-grid-layouts-on-the-fly-without-a-framework/ interesting css frameworks http://www.bluetrip.org/ http://www.devarticles.com/c/a/Web-Style-Sheets/Introducing-the-BlueTrip-CSS-Framework/ http://daneden.me/toast/ https://github.com/coyr/nivelstyle https://code.google.com/p/logicss/ http://toddmotto.com/introducing-superbox-the-reimagined-lightbox-gallery/1 point
-
I just pushed ProcessWire v2.3.1 to the dev branch. This is a fairly major change in that it switches the DB driver from mysqli to PDO. It meant changes to a large percentage of core files. ProcessWire still supports mysqli, but doesn't attempt to use it unless a module or a template asks for it via the $db API variable. The new API variable (for the PDO driver) is $database. More about PDO at php.net If you are using the dev branch, be careful and test thoroughly with this latest commit to it. Before upgrading, you may want to double check that your PHP supports PDO by looking at your phpinfo (CMD-F or CTRL-F for "PDO"), especially if you are running PHP 5.2.x (where PDO wasn't compiled in by default). Though if you are running PHP 5.2 (vs 5.3.8+) then you may want to just stick with ProcessWire 2.3.0 and upgrade your PHP version when possible. If you are using any modules that use the procedural version of mysqli functions (vs. the $this->db object oriented versions), or type-hint mysqli in methods, then those modules will no longer work. If you come across any modules that don't work with 2.3.1, please let me know here so that I can assist the author in updating them. Note that FormBuilder is one of the modules that does not work with 2.3.1, but I have posted an update in the FormBuilder board that corrects it–so be sure to download that version if you are tracking the dev branch of ProcessWire and using FormBuilder. What this new version adds: 1. New API variable $database that refers to the PDO database. The old $db API variable is still there and refers to mysqli for any modules that continue to use it. 2. New API variable $log that lets you easily log messages or errors to the system logs. Usage: $log->message("This saves this line to messages.txt"); $log->error("This saves this line to to errors.txt"); $log->save("my-log", "This saves this line to my-log.txt"); // Get an array of the last few entries saved to the messages log $entries = $log->get('messages'); // Get an array of the last 50 entries saved to my-log $entries = $log->get('my-log', 50); Note that as always, log files are located in /site/assets/logs/. 3. Conditional autoload modules. In PHP 5.3+, modules may now specify an anonymous function OR a selector string, rather than a boolean for the 'autoload' property returned by getModuleInfo(). PW runs the anonymous function after determining the current $page, so your module can make autoload decisions based on the $page (or any other factor you'd like), if desired. Lets say that we have a module that we only want to autoload when the template is 'admin': public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => function() { if(wire('page')->template == 'admin') return true; else return false; }); } And the same example but using a selector for autoload: public static function getModuleInfo() { return array( 'title' => 'Module Title', 'summary' => 'Summary text...', 'version' => 1, 'autoload' => 'template=admin' ); } 4. Addition of $pages->add() method. Actually $pages->add($template, $parent, [string $name], [array $values]); This function adds a new page to the database and returns it. This is for syntax convenience, but using the old method is still perfectly fine too. Here's a few examples of usage: // add a new page using template basic-page under /about/ $newpage = $pages->add('basic-page', '/about/'); // same as above, but named 'contact' $newpage = $pages->add('basic-page', '/about/', 'contact'); // same, but populate the title field too $newpage = $pages->add('basic-page', '/about/', 'contact', array('title' => 'Contact Us')); // you can also do this, specifying the values array as 3rd argument: $newpage = $pages->add('basic-page', '/about/', array('title' => 'Contact Us')); $template and $parent are required, but may be objects, IDs, or string identifiers (like name for template, or path for page). When you add a new page and don't specify a 'name', then PW will make one up, guaranteed to be unique. 5. Module files that end in '.module.php' are now supported. So rather than ClassName.module, you may use ClassName.module.php if you prefer it. The purpose here is to support text editors that determine their syntax highlighting based on the file extension. More updates being made almost daily. Please report any issues you experience. Thanks, Ryan1 point
-
This is a quick tip for my front-end developer peeps and other wanna-be-coders like me....I have been seeing this "strange" <?php endif; ?> code in some code here in the forums and in some template files. <?php if ($a == 5): ?> <p>A is equal to 5</p> <?php endif; ?> //In the above example, the HTML block "A is equal to 5" is nested within an if statement written in the alternative syntax. The HTML block would be displayed only if $a is equal to 5. //The alternative syntax applies to else and elseif as well. I have largely ignored it until I read about it more and wow! I wish I knew about it earlier. Anyway, you might want to read up about it. In a nutshell, it makes mixing PHP and HTML much more friendly in some cases. It helps avoid echoing out a lot of HTML but instead gives you flexibility to just type them out normally... A few resources to help you understand the alternative syntax. http://php.net/manual/en/control-structures.alternative-syntax.php http://www.brian2000.com/php/understanding-alternative-syntax-for-control-structures-in-php/ http://www.stoimen.com/blog/2010/03/10/php-if-else-endif-statements/ http://www.trans4mind.com/personal_development/phpTutorial/controlStructures.htm http://stackoverflow.com/questions/564130/difference-between-if-and-if-endif http://stackoverflow.com/questions/6023418/when-do-i-use-if-endif-versus-if http://www.trans4mind.com/personal_development/phpTutorial/controlStructures.htm1 point
-
This is all more PHP than ProcessWire. All that ProcessWire does is that template files have some predefined variables for nicer api. $page and $pages are among those. Includes are different beast from functions (and from modules). If you include a file, it has all the same variables than the file that included it. So if you include a file from your template file, the included file will have $page and $pages available. Functions have scope. So when you have this code in your template: <?php renderTitle(); function renderTitle() { echo "<h1>$page->title</h1>"; } It will not work, since renderTitle() function doesn't know what $page is. Here is working version of the same template file: <?php renderTitle(); function renderTitle() { $page = wire('page'); echo "<h1>$page->title</h1>"; } or always possible to pass variables: <?php renderTitle($page); function renderTitle($page) { echo "<h1>$page->title</h1>"; }1 point
-
That has been my nightly reading for the past two weeks.1 point
-
I just had another project popup. But the last thing I want to do with my PWFoundation project is to convert the default install to Foundation and make it fully responsive. After I have that done, I'll throw it up on my github for others to check out.1 point
-
1 point
-
So then, would be interesting to know, who is using what css framework and why - - - - ? and who is coding his own responsive css layout and how - - - - ? Example would be nice.1 point
-
Hi OrganizedFellow, the Foundation project you are working on sounds great. Thank you very much for sharing, I can't wait to try it out.1 point
-
What I do in a similar situation is save the value ob page save to a field outside repeater. Makes for easy and fast searching with limits and pagination.1 point
-
@Ovi, I have to take a closer look to your solution, it sure sounds interesting. PW uses usort for in-memory sorting because it's stable (=doesn't change order of equal items relative to each other) while quicksort isn't. But it seems I've got to dig a bit deeper on this sometimes (and make some speed comparisons) to see if PW could benefit from a stable variation of quicksort - thanks for sharing your findings on that. Then the actual point I was supposed to make: the solution in my previous post (last one on first page) doesn't use usort at all but leaves the sorting to MySQL. And that's the preferred way both for speed and memory consumption. But as it didn't fit your needs (the thread you linked to) the solution you came up with seems like a very good one too.1 point
-
Thanks Nik, but i came up with my own solution meanwhile. The good part is that i don't user uSort i use an implementation of the QuickSort algorithm, which should be 3 times faster than uSort. Useful Links: explanation of Quicksort algorithm: http://en.wikipedia.org/wiki/Quicksort php implementation of Quicksort by Iskren Stoianov: http://istoyanov.blogspot.ro/2007/11/quicksort.html My setup: i have an online store with products. all products have the same template products have price variations depending on quantity (small box of product vs big box of the same product) - it is not a matter of shipping more of the same product, the diferent sizes come from the manufacturer (cosmetic products) product variations are stored in a repeater called "product_variations" which has the fields "size" and "price" categories and subcategories share the same template. The difference is that categories have sub-categories as children. The challenge: sorting the products by price. Since there can be multiple prices for a product (one for each variation) i want to sort the products by the FIRST variation's price. The solution: function quickSortProducts( &$array, $sort_order="ASC" ){ if ($sort_order!= "ASC" && $sort_order != "DESC") { trigger_error("Invalid paramenter ".$sort_order." . Expecting ASC or DESC", E_USER_ERROR); } $cur = 1; $stack[1]['l'] = 0; $stack[1]['r'] = count($array)-1; while( $cur != 0 ){ $l = $stack[$cur]['l']; $r = $stack[$cur]['r']; $cur--; while( $l < $r ){ $i = $l; $j = $r; $tmp = $array[(int)( ($l+$r)/2 )]; // partion the array in two parts. // left from $tmp are with smaller values, // right from $tmp are with bigger ones while( $i <= $j ){ if ($sort_order == "DESC") { while( $array[$i]->product_versions[0]->price > $tmp->product_versions[0]->price ) $i++; while( $tmp->product_versions[0]->price > $array[$j]->product_versions[0]->price ) $j--; }else{ while( $array[$i]->product_versions[0]->price < $tmp->product_versions[0]->price ) $i++; while( $tmp->product_versions[0]->price < $array[$j]->product_versions[0]->price ) $j--; } // swap elements from the two sides if( $i <= $j){ $w = $array[$i]; $array[$i] = $array[$j]; $array[$j] = $w; $i++; $j--; }// end if };// end while ( $i <= $j ) if( $i < $r ){ $cur++; $stack[$cur]['l'] = $i; $stack[$cur]['r'] = $r; } $r = $j; }; // end while ( $l < $r ) }// end while( $cur != 0 ); }// end function quickSortProducts This function does all the sorting. Next i put together my query. Since categories and sub-categories share the same template, i need to figure out what the scope of the query is and i do that below. If you don't have the same setup just do whatever query you need to. This part has nothing to do with the sorting, just putting it here for completeness: // set the scope of the query if ($page == $page->rootParent) { // this is a category, we need the categories from all it's children subcategories $categoryScope = $page->rootParent->category_field_name; }else{ // this is a sub-category, we only need the products from itself $categoryScope = $page->rootParent->category_field_name; } // do the PW query $products = $pages->find("template=product, ".$categoryScope."=$page->children"); And finally, after we've done the query and we have our collection of product pages, we sort it by calling the custom function: if ($input->urlSegment1 == "price-ascending") { quickSortProducts( $products, "ASC") }elseif($input->urlSegment1 == "price-descending"){ quickSortProducts( $products, "DESC") }1 point
-
I was looking at brakets with much interest as an open-source software, but this makes me think that it will be just another adobe family product... Don't get me wrong, i understand that business is business, but it does turn my curiosity down a bit because I can imagine that 90% of their effort will have to do with making it work with other adobe products instead of focusing in the real text editor developing challenges. I may be wrong though...1 point
-
Kongondo, you should get some kind of forum member award. What you are posting lately is really amazing and helpful for pw users with little coding expierence. Thanks !1 point
-
This is the normal behaviour when installing ProcessWire - the folder is renamed to /site/. In Pw, your files of the website are all inside the /site/ folder. There exist several profiles you can install with Pw:http://modules.processwire.com/categories/site-profile/ /site-default/ is just the default profile included in the download. Because you did not install Pw locally, you have to rename your /site-default/ manually. But better workflow IMO is to install Pw locally and then transfer the files to your FTP.1 point
-
And we have you to thank for hiring him in the first place which led us to Hanna Code! Thank you!1 point
-
What kills me about this module is that Ryan literally decided to make it because I had something similar in WordPress and needed a substitute solution in ProcessWire (as part of the move of CMS Critic to PW) otherwise I'd have a ton of weird shortcodes in my posts for no reason. He made this module, imported my code from the other module (called Hana Code in WP) and named his Hanna Code (after his daughter) and Poof! a module is born. I am insanely jealous of his mad php skills (but glad they can be bought!)1 point
-
OK, now we're back on track I think. So, you've lined up those three things to use page id's? Then your search form would be like this: <select name="location"> <option value="">any</option> <?php foreach($pages->get("/")->children("id!=10") as $location) { $selected = $location->id == $input->whitelist->location ? " selected='selected' " : ''; echo "<option$selected value='{$location->id}'>{$location->title}</option>"; } ?> </select> And now you could use something like this in search.php: # has a location been selected? if($input->get->location) { # sanitize (page id is always an integer) # no need to fetch the actual page as the search selector restricts results to employees $location = (int)$input->get->location; # employees have template 'employee' and their parent page is the chosen location $selector .= "parent={$location}, template=employee"; # whitelist the sanitized value (and use from whitelist later on) $input->whitelist('location', $location); } Hope I didn't introduce any new errors there...1 point
-
if (wire('input')->post->submit)) { ... } Inside functions, the API variables are out of scope. That's a PHP thing. So for every API variable, use the global function wire('api_var_here').1 point
-
1 point
-
Hi, yes. If possible use foundation starter template (http://foundation.zurb.com/templates.php) then export as a site profile. I have seen Bootwire made by Joss, Its a brilliant profile. I'm thinking about the alternative possibilities explained in the thread - "A different way of using templates / delegate approach"1 point
-
Hi Apeisa, I am just realizing how amazing PW actually is. (I'm a little slow at times )!! Ryan has done a great job. I guess I'm curious to find out how the experts do it! Because PW is so flexible there are so many solutions. The post started by Soma was an interesting read. http://processwire.com/talk/topic/740-a-different-way-of-using-templates-delegate-approach/. Has anyone changed their workflow since the thread was started in 2011? I would be very interested to see how a page eg. template from Foundation 4 (http://foundation.zurb.com/page-templates4/workspace.html) could be tackled by a couple of members.1 point
-
Hi pitbull Download the fullcalendar from the link below http://arshaw.com/fullcalendar/download/ Upload the fullcalendar.css , fullcalendar.print.css and fullcalendar.js to your server end embedded in your page header like this <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates ?>assets/css/styleaahaeota.css"> <link href='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.css' rel='stylesheet' /> <link href='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.print.css' rel='stylesheet' media='print' /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script src="<?php echo $config->urls->templates ?>assets/js/bootstrap.js"></script> <script src='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.js'></script> add the code below in your header after the <script src='<?php echo $config->urls->templates ?>assets/calendar/fullcalendar.js'></script> <script> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: false, events: "http://weborange.gr/aahaeota/json-events.php", eventRender: function(event, element, view ) { var image = '<img src="'+event.img+'" />'; if (view.name === "agendaDay") { element.find('.fc-event-title').append("<br/>" + event.description); } // on event hover pop up a small discription of the event and an image, // i use bootsrap framework so popoever is curently works only for // bootsrap details in http://twitter.github.io/bootstrap/javascript.html#popovers //if you dont want this, delete it or take the code from my last post element.popover({ html: true, trigger: 'hover', title: event.title, placement: 'top', content: image + '<span class="calendar-detail-time"> ' + event.ddate + ' until ' + event.dend + '</span>' + '<br/>' + event.description , }); }, eventDrop: function(event, delta) { alert(event.title + ' was moved ' + delta + ' days\n' + '(should probably update your database)'); }, loading: function(bool) { if (bool) $('#loading').show(); else $('#loading').hide(); } }); $oldTable.remove(); }); </script> create a new php file called json-events.php and upload it in your root folder. Inside json-events.php add the below code <?php include("index.php"); // bootstrap ProcessWire function pagesToJSON(PageArray $events) { $json = array(); foreach($events as $event) { $json[] = pageToArray($event); } return json_encode($json); } function pageToArray(Page $event) { $data = array( 'id' => $event->id, 'title' => $event->title, 'start' => date("Y-m-d H:i",$event->date_start), 'end' => date("Y-m-d H:i",$event->date_end), 'url' => "$event->url", // event ID is the url segment 'description' => "$event->summary", //event summary for bootsrap popover 'allDay' => false, 'img' => $event->images->first()->url, //event image for bootsrap popover 'ddate' => date("d-m-Y H:i",$event->date_start), //event date start for bootsrap popover 'dend' => date("d-m-Y H:i",$event->date_end), //event date for bootsrap popover ); return $data; } // end else $eventPage = $wire->pages->get('/events/')->children(); echo pagesToJSON($eventPage); ?> and final in the template that you want to render the calendar add <div class="tab-pane" id="calendary"> <div id='loading' style='display:none'>loading...</div> <div id='calendar' class='calendar-page'></div> </div> that's it, you can see example here just go one month before from the upper left arrows sorry for my bad english , i hope that this is going to help you1 point
-
1 point
-
Hey all, I've converted the ProcessWire 2.3 rules to Nginx. Hope this will help some people Greetings, Niek server { listen 80; listen 443 ssl; root /var/www/example.com/public_html; server_name example.com www.example.com; ssl_certificate /etc/pki/tls/certs/example.com.crt; ssl_certificate_key /etc/pki/tls/private/example.com.key; client_max_body_size 50m; access_log /var/www/example.com/_logs/access.log; error_log /var/www/example.com/_logs/error.log; # ----------------------------------------------------------------------------------------------- # Set default directory index files # ----------------------------------------------------------------------------------------------- index index.php index.html index.htm; # ----------------------------------------------------------------------------------------------- # Optional: Redirect users to the 'www.' version of the site (uncomment to enable). # For example: http://processwire.com/ would be redirected to http://www.processwire.com/ # ----------------------------------------------------------------------------------------------- if ($host !~* ^www\.) { rewrite ^(.*)$ $scheme://www.$host$1 permanent; } # ----------------------------------------------------------------------------------------------- # Access Restrictions: Protect ProcessWire system files # ----------------------------------------------------------------------------------------------- # Block access to ProcessWire system files location ~ \.(inc|info|module|sh|sql)$ { deny all; } # Block access to any file or directory that begins with a period location ~ /\. { deny all; } # Block access to protected assets directories location ~ ^/(site|site-[^/]+)/assets/(cache|logs|backups|sessions|config|install|tmp)($|/.*$) { deny all; } # Block acceess to the /site/install/ directory location ~ ^/(site|site-[^/]+)/install($|/.*$) { deny all; } # Block dirs in /site/assets/ dirs that start with a hyphen location ~ ^/(site|site-[^/]+)/assets.*/-.+/.* { deny all; } # Block access to /wire/config.php, /site/config.php, /site/config-dev.php, and /wire/index.config.php location ~ ^/(wire|site|site-[^/]+)/(config|index\.config|config-dev)\.php$ { deny all; } # Block access to any PHP-based files in /templates-admin/ location ~ ^/(wire|site|site-[^/]+)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$ { deny all; } # Block access to any PHP or markup files in /site/templates/ location ~ ^/(site|site-[^/]+)/templates($|/|/.*\.(php|html?|tpl|inc))$ { deny all; } # Block access to any PHP files in /site/assets/ location ~ ^/(site|site-[^/]+)/assets($|/|/.*\.php)$ { deny all; } # Block access to any PHP files in core or core module directories location ~ ^/wire/(core|modules)/.*\.(php|inc|tpl|module)$ { deny all; } # Block access to any PHP files in /site/modules/ location ~ ^/(site|site-[^/]+)/modules/.*\.(php|inc|tpl|module)$ { deny all; } # Block access to any software identifying txt files location ~ ^/(COPYRIGHT|INSTALL|README|htaccess)\.(txt|md)$ { deny all; } # Block all http access to the default/uninstalled site-default directory location ~ ^/site-default/ { deny all; } # ----------------------------------------------------------------------------------------------- # If the request is for a static file, then set expires header and disable logging. # Give control to ProcessWire if the requested file or directory is non-existing. # ----------------------------------------------------------------------------------------------- location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|eot|woff|ttf)$ { expires 24h; log_not_found off; access_log off; try_files $uri $uri/ /index.php?it=$uri&$args; } # ----------------------------------------------------------------------------------------------- # This location processes all other requests. If the request is for a file or directory that # physically exists on the server, then load the file. Else give control to ProcessWire. # ----------------------------------------------------------------------------------------------- location / { try_files $uri $uri/ /index.php?it=$uri&$args; } # ----------------------------------------------------------------------------------------------- # Pass .php requests to fastcgi socket # ----------------------------------------------------------------------------------------------- location ~ \.php$ { # Check if the requested PHP file actually exists for security try_files $uri =404; # Fix for server variables that behave differently under nginx/php-fpm than typically expected fastcgi_split_path_info ^(.+\.php)(/.+)$; # Set environment variables include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; # Pass request to php-fpm fastcgi socket fastcgi_pass unix:/var/run/example.com_fpm.sock; } }1 point
-
I'm going to jump in, hopefully not just to mess things up . One dirty way to achieve what you're trying to do would be going straight to the repeater items. This gives you the top 5 highest mountains across all reports: $topFiveMaxElevations = $pages->find("template=repeater_mountains, sort=-stats_maxElev"); Technically repeater items are pages and thus you can use find() as you'd do for normal pages. But as I said, I'd consider this a dirty way because it relies on the internals of the repeater fieldtype. It does get you there but at what cost, that I don't really know. And if you'd need any data from the parent page (the report itself), you'd need to get it via getForPage() which returns the page a repeater item belongs to. And like Soma pointed out, there's some redundancy. That could affect the top 5 lists the very moment some mountain ends up in two different reports (unless it's absolutely impossible scenario?). No matter which method you use to collect for example the altitude data, you'd probably need some check to filter out duplicates. And that would make things a bit more difficult as you wouldn't be able to limit to 5 results right away. Oh well, just wanted to mention it. Actually that's what the manual says it will do . See http://php.net/manual/en/function.usort.php where it says "The comparison function must return an integer less than, equal to, or greater than zero" with an additional caution on using for example floats. Your solution is fine though, now you've got it returning integers. Hope I was being helpful, rather that confusing. Time to get some sleep now.1 point