Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/07/2021 in all areas

  1. This week ProcessWire gained powerful new tools for finding pages and controlling how they are loaded. If you like to maximize performance and efficiency, you’ll like what 3.0.172 brings— https://processwire.com/blog/posts/find-faster-and-more-efficiently/
    2 points
  2. This is great, but I've encountered a possible bug, unless I'm doing something wrong. As a test I used it to create a simple site map using a recursive function -- besides the page title, I also wanted a 'headline' field, so it seemed a good candidate for an autojoin test. When I ran it, however, there were some unexpected results (missing child pages and missing page names in urls) with the autojoin feature. Here is the plaintext output from my tests (correct version first, then the incorrect version): Notes: C = hasChildren / numChildren (same result) $p = current Page object being traversed In both cases, the sort order is default (manual sort in the backend). All pages use the same template (so definitely contain the fields being autojoined). In all cases, both the 'title' and 'headline' fields were present in the output, so I omitted them below. This is the recursive function I'm using: // Called with: siteMap($pages->get(1)) function siteMap(Page $p) { $str = ''; $children = $p->children('join=title|headline'); // with autojoin // $children = $p->children(); // without autojoin foreach ($children as $c) { $str .= $c->id . " " . $c->hasChildren() . " " . $p->id . " " . $c->url . "\n"; if ($c->hasChildren()) { $str .= siteMap($c); } } return $str; } The following methods all produce the same incorrect results: $p->children('join=title|headline'); wire('pages')->find('parent='.$p.', join=title|headline'); wire('pages')->findJoin('parent='.$p, 'title,headline'); wire('pages')->findJoin('parent='.$p, ['title','headline']); Furthermore, it made no difference if I used "field" or "join" as the keyword in the selector. ProcessWire 3.0.172 (DEV) PHP 7.2.0 MySQL 5.7.19
    2 points
  3. This is a fun, simple project I built over the holidays and really goes back to what initially drew me to ProcessWire several years ago after being inspired by Ryan's Skyscrapers Demo. Backwards Compatible allows searching and browsing by various performance related tags and game pages display detailed data on each title. List of modules used: Import Pages by CSV - Essential for this kind of site, the vast majority of data was imported in one CSV upload Procache - Invaluable after an influx of 650k page views in 6 days(!) Form Builder - A simple implementation for monitored page updates and YT video submissions Soma's AjaxSearch Mike Rockett's Sitemap Additional styles/scripts: Bootstrap Grid only for CSS Fancybox.js Tippy.js Commento
    1 point
  4. Great additions - many of these are things that we have setup our own solutions when hitting performance issues on large scale (10 000+ pages with lots of fields) so it is great to see core supporting this kind of things. Thank you Ryan! Quick note on findRaw - it looks like it doesn't support parent? It would be very powerful to be using parent just like any normal field based page relation.
    1 point
  5. @LMD Thanks, it looks like a last minute optimization screwup on my part, changing a $page->set() to a $page->setForced(), when there was bug in $page->setForced() preventing it from populating $page->settings when it should. I have pushed a fix for it on the dev branch. Please let me know if you continue to see any errors.
    1 point
  6. For advanced needs there is a module from @Robin S : https://processwire.com/talk/topic/21153-access-by-query-string/ But if you need something really quick and simple, just put that in your init.php: if($input->get('code', 'string') === 'YOURSECRET') { // remove the unpublished state in memory (non-persistant) $pages->get('/yourpage')->removeStatus('unpublished'); } This makes /yourpage accessible via /yourpage/?code=YOURSECRET ? PS: I had this need today to show a page to a user that has no login and to make sure that the page is also excluded from search results (that's why just hiding the page would not have been enough).
    1 point
  7. Keeping template snippets / functions in the code can be achieved with ob_start / output buffering. Note how you can inject the $page object into the function - and continue using the ProcessWire API inside the function - that's highly useful. This solution works with your IDE and is based on vanilla PHP. Compared to Hanna Code, this solution allows you to keep all code in the file system. Compared to heredoc and nowdoc, this solution allows you to use PHP / ProcessWire code in the snippet. It's almost like using the Twig and Smarty template engines only it works out of the box, it doesn't add additional overhead and you don't need to learn a proprietary template language. functions.php: function uk_subnav_pill($title,$page,$selector) { if($page->children($selector)->count>0): ob_start(); ?> <li class="uk-active"> <a href="#"><?=$title?> <span uk-icon="icon: triangle-down"></span></a> <div uk-dropdown> <ul class="uk-nav uk-dropdown-nav"> <?php foreach ($page->children($selector) as $p): ?> <li class="uk-list-hyphen"> <a href=#<?=$p->name?>><?=$p->title?></a> </li> <?php endforeach; ?> </ul> </div> </li> <?php return ob_get_clean(); endif; } include your functions file in init.php (I use the delayed output template file strategy but of course the function file can also be included directly in the template file - it's up to you): include 'includes/functions.php'; Then call the function in your template file: <ul class="uk-subnav uk-subnav-pill" uk-margin> <?=uk_subnav_pill('Foos',$page,'template=foo')?> <?=uk_subnav_pill('Bars',$page,'template=bar')?> <?=uk_subnav_pill('Bazs',$page,'template=bar')?> </ul>
    1 point
×
×
  • Create New...