Jump to content


  • Content Count

  • Joined

Community Reputation

61 Excellent

About LMD

  • Rank
    Full Member

Profile Information

  • Gender
    Not Telling
  • Location

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. @ryan - I have just encountered the exact same issue here when trying to paginate a PageArray which has autojoined fields -- without autojoin the pagination works as expected, with it getTotal() shows the wrong number. Edit: this is with the newest DEV branch version of ProcessWire: ver. 3.0.175
  2. I had a thought about findRaw from a use-case I have (a flag set on pages via $page->meta() on save). I don't know how feasable it is, but it would neat if it was possible to join the contents of 'pages_meta' onto findRaw/getRaw queries. Nothing fancy, all it would need to do is return the raw data (just like any fieldtype that gets joined) as an array indexed by meta key. $p = $pages->findRaw('template=foobar, parent=1234', ['title', 'pages_meta']); /* Would return, for example: [5678] => [ 'title' => 'The Page Title', 'pages_meta' => [ 'foo' => 'Plain String', 'bar' => '{"a":"JSON","b":"String"}' ] */
  3. I never did like October 😄 ! I've fixed the code.
  4. Oh my, this is excellent! A first use case I thought of was archives (eg. blogs) filtered by date: YYYY/MM/DD /** * This example merely displays back the selected date as a string, but it could be used to show date-based archives. * The following URLs are valid: * /YYYY * /YYYY/MM * /YYYY/MM/DD */ // Build basic date regex to eliminate very silly things (e.g. 2021/15/92) $dateRegexY = '(year:\d{4})'; // any four digits (could be narrowed, e.g. '(19|20)\d{2}' $dateRegexM = '(month:(0[1-9]|1[0-2]))'; // 01-09 or 10-12 $dateRegexD = '(day:(0[1-9]|[1-2][0-9]|3[0-1]))'; // 01-09, 10-29, 30-31 (will need further validation!) // Put it together $dateRegex = '/' . $dateRegexY . '(/' . $dateRegexM . '(/' . $dateRegexD . ')?)?'; $wire->addHook($dateRegex, function($event) { $date = $event->year . ($event->month ? '/' . $event->month : '') . ($event->day ? '/' . $event->day : ''); return $date; }); The possibilities are endless.
  5. Without needing to buy a Pro module (although they are excellent!), there is indeed a ProcessWire way for this. You can use $files->render()/wireRenderFile() to achieve what you want: https://processwire.com/api/ref/wire-file-tools/render/ https://processwire.com/api/ref/functions/wire-render-file/ The advantage of using this over your own functions is that it will automatically keep access to all of PW's API variables (no need to pass them in). Here is a simple example based on your use-case description: /** * In your generic template file. * Note: it assumes there is a directory under 'templates' called 'layouts' (it could be called anything). * Just create your layouts in the 'layouts' dir and name them the same as the '$item->template' names you are using. */ // Get the content of the specified layout into a variable. // This example looks for '/site/templates/layouts/name-of-template.php' (the .php extension is assumed) $pageContent = $file->render('layouts/' . $item->template); // Just echo it out wherever you need it. echo $pageContent; Read the docs on it, there is more you can do with this method/function, including passing custom variables, and some other options to make it more flexible. There is also a $files->include() method which is the same except it directly echos out the content instead of returning it to a variable.
  6. Thanks Ryan, the update fixed the problem.
  7. 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
  8. [Edit: I probably should have tagged @gebeer.] Hi, I came across a use-case today that I wondered if it would be possible to add? It would be super useful to have the option to include child pages in the "Pick from the page being edited" and also "Pick from any page" source options. Furthermore, it would really useful if, when "include child pages" is selected (for all source options), the parent page being edited itself did not need to contain an image field. My use case is the following set-up: Gallery Collection 1 <-- contains 'image reference' field, but no 'images' field of its own. Album 1 <-- contains the 'images' field for a group of related image (e.g. different view of the same object). Album 2 Album Collection 2 Album 1 Etc... The parent "collection" template has an image reference to choose an image from one of the child album templates to serve as its "cover image". It would be even cooler if, as well as specifying the images field to select from, you could also specify images having a particular tag (if tags are used). But that might be asking for the moon 😄 !
  9. Thanks. I will look more closely at CroppableImage.
  10. @Robin SThank you for a perfectly timed module! I have a wishlist suggestion - as well as the fixed ratios, would it be feasible/possible to also include a minimum size for the crop area? For example, a banner image (used in your own screencast demo) might have a minimum width requirement. It is easy to shrink a larger cropped area, but obviously, a smaller area can not be "embiggened" without pixelation. Maybe it could be specified along with the ratio (e.g., using a comma): Banner Image=2:1,800:400 Technically, you'd only need to specify the length of the longest side.
  11. Oh, sorry, I don't have a RepeaterMatrix field in operation anywhere at the current time.
  12. Works like a charm for me, both outside and inside repeaters. Thank you, @gebeer!
  13. No, it's in my dev environment and I'm the only user (superuser). While I think of it, I also ensured the pages were 'published' and not 'hidden', in case that was the problem (it wasn't).
  14. Hi @gebeer, I tested the update this morning and oops... I don't know what happened this time, but it no longer works at all either inside or outside of a repeater. it just loads a clone of the page currently being edited. It's hard to explain, so this GIF should illustrate what's happening (this is a test outside of a repeater): The above demonstrates the "choose an image from page" and "choose any page" options. The field settings are correct - they are same ones that worked (outside of a repeater) previously. There are images available! I tried the other options (from a folder etc) and exactly the same thing happens. I uninstalled all other modules in case there was a JS conflict and still the same thing happens. In case it helps, here is the console log: I'm using ProcessWire version 3.0.147 and PHP 7.2. Happy New Year! (?)
  15. Hi @gebeer - thanks for this module. I'm having an issue when using it with repeaters, though. Previously I used the "FieldtypeImageFromPage" module which worked perfectly in repeaters, but swapped to this more flexible module and now get the following errors which prevents the field working (no image picker section available -- see screenshot after): Notice: Trying to get property 'data' of non-object in \site\modules\FieldtypeImageReference\InputfieldImageReference.module on line 58 Warning: Invalid argument supplied for foreach() in \site\modules\FieldtypeImageReference\InputfieldImageReference.module on line 58 As you can see, there is no way to pick an image (clicking on the blank area does nothing) -- the field is set-up correctly, because it works outside of a repeater without problems! I think the problem is that the module is getting the field settings data by fieldname, but of course, in a repeater the fieldname is changed to "fieldname_repeater####", causing the issue. It appears to be this line (58) : foreach($this->wire('fields')->get($this->name)->data as $key => $value) { In a repeater, $this->name is looking for "fieldname_repeater####" which returns a non-object, making the foreach bork.
  • Create New...