Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/05/2023 in all areas

  1. @nbcommunication Yes, you are right, it's nice it's working with JSON, and nice that it's well documented. These things already make it well above average. Despite being simple to consume JSON, one thing I find a bit painful is the lack of granularity in the API. There's a lot of cases where I want to get one thing or another, but I have to get the entire 800kb structure of things and parse the one thing I need out of it. It seems like this will just not be feasible at some scale. When it comes to putting data into the system, you have to construct a large JSON object and manipulate it as a whole rather than being able to insert or modify individual parts. Maybe this is standard for APIs like this, I don't know. It seems cumbersome at times.
    1 point
  2. Hi @Pete, sorry to resurrect this in 2023, but I can't login at https://directory.processwire.com/login/, I am getting a red pop-up saying There was an error processing your details. Please try again. I tried in incognito and in a different browser with no historic session info. I am attempting to login in order to change my bio in the Developer Directory (I assume this is the right spot to do that). Thanks very much for any help : ) Cheers, Alan
    1 point
  3. I'm currently in the process of implementing a naive selector parser and querying engine for the processwire database layout using elixir. This is for a talk I'll be giving in a few month, which is meant so showcase the flexibility of a database library, so this is not going into production or anything, but I'd still wonder about something I bumped into when working on this. I also might bump into more things, so I'll dedicate this thread to potential future questions as well. When I looked into supporting `parent=…`/`has_parent=…` I started by joining `pages_parents`, but the new pages I had just added via the processwire admin moments before weren't present in that table. This was on an otherwise fresh installation. Aren't all pages supposed to be present in `pages_parents` and if not, what would be the conditions for them being present or not? I vaguely remember having run into issues with that table being out of date in the past, but I always blamed myself and whatever I did, not the system. Edit: $pages->parents()->rebuildAll(1); This seems to have fixed the data in the table, but for some reason using it without the (documented to be optional) id it rebuilt the table incorrectly as well. See context below
    1 point
  4. Almost every time. I think we're just a bit spoiled with the PW API, but it is always a bit of a shock to work with API data that needs to be wrestled into shape before we can do what we want to do. I'm not sure I could even wrestle it into shape if it wasn't for PW.... On the plus side, at least that API is documented and returning JSON ?
    1 point
  5. This week we've got a few minor issue fixes and a couple of pull request additions on the dev branch. Pull request #251 thanks to @Jan Romero added a download button to the thumbnail images in InputfieldImage. I wasn't sure we really needed that, but really liked his thinking behind it, which was envisioning the ability to add more custom buttons/actions for images. So while I didn't specifically add the download button, I added the proposed system for adding any custom buttons, and then applied that same thinking to some other parts of InputfieldImage. And we'll talk about how to add that Download button here. ? First, let's look at how you might add your own download button, and note we're using this as just an example, as you might add any kind of button this way. A new hookable getImageThumbnailActions() method was added for this purpose. So here's how you might hook it (in /site/ready.php) to add a download button: $wire->addHookAfter('InputfieldImage::getImageThumbnailActions', function(HookEvent $event) { $image = $event->arguments(0); // Pageimage $class = $event->arguments(3); // class to use on all returned actions $a = $event->return; // array $icon = wireIconMarkup('download'); $a['download'] = "<a class='$class' href='$image->url' download>$icon</a>"; $event->return = $a; }); With that hook in place, here's what it looks like when you hover a thumbnail image. And if you click that Download icon, it downloads the file to your computer: or in list mode (download icon appears in right corner next to trash): I was thinking it would be useful to also be able to add custom actions after you click the thumbnail, and it shows the image edit features. So let's add a Download button there instead, by hooking the new getImageEditButtons() method: $wire->addHookAfter('InputfieldImage::getImageEditButtons', function(HookEvent $event) { $image = $event->arguments(0); // Pageimage $class = $event->arguments(3); // class(es) to use on all returned actions $buttons = $event->return; // array, indexed by action name $icon = wireIconMarkup('download'); $buttons['download'] = "<button class='$class'><a download href='$image->url'>$icon Download</a></button>"; $event->return = $buttons; }); And the result looks like this (see new Download button after Variations button): We also have that Actions dropdown that you see in the screenshot above. This is already hookable but we've not had any good examples of it. In this case, you need two hooks: one to add the action to the <select> and another to handle the processing of the action when the page is saved. So in our next example, we'll demonstrate how to display verbose EXIF information about whatever image(s) the action was selected for. In this first hook, we'll add the action to the Actions <select>: // Example of adding an “Get EXIF data” action to the <select> $wire->addHookAfter('InputfieldImage::getFileActions', function(HookEvent $event) { $image = $event->arguments(0); // Pageimage if($image->ext == 'jpg' || $image->ext == 'jpeg') { $actions = $event->return; // array $actions['exif'] = 'Get EXIF data'; $event->return = $actions; } }); And in this next hook, we'll handle the action, which gets called when the page editor form is submitted: // Example of handling an “Get EXIF data” action $wire->addHookAfter('InputfieldImage::processUnknownFileAction', function(HookEvent $event) { $image = $event->arguments(0); $action = $event->arguments(1); if($action === 'exif' && file_exists($image->filename)) { $exif = exif_read_data($image->filename); $event->warning([ "EXIF data for $image->name" => $exif ], 'icon-photo nogroup'); $event->return = true; } }); And here's what it shows after you hit save (for any images that had the action selected): The screenshot above is truncated because it was about twice is big as what's above. All the above code examples are also included in the phpdoc for each of the relevant hookable methods in the InputfieldImage module. For another recent useful addition, be sure to check out ProcessWire Weekly #454 (last week) which covered some new options available for the language translation functions like __text('hello'); where you can now tell it what kind of input type (and how many rows) to use in the admin translation interface, via inline PHP comments. Thanks for reading and I hope you have a great weekend!
    1 point
  6. Hey @ryan thx for the additions! And thx @Jan Romero for the PR! I think a download button is a must have on image fields, so for my taste it should be default, but until then I've added a tweak to RockMigrations (v2.15.0) so the download buttons are just a checkbox away ?
    1 point
  7. Here's an example... The page structure: Some pet species have breed child pages and some do not. The selector string for selectable pages for the breed field is "parent=page.species". In ready.php: $wire->addHookAfter('ProcessPageEdit::buildForm', function(HookEvent $event) { /* @var InputfieldForm $form */ $form = $event->return; $breed_field = $form->getChildByName('breed'); if(!$breed_field) return; $species_with_breeds = $event->wire('pages')->find('parent=/selects/pets/, children.count>0'); $breed_field->showIf = 'species=' . $species_with_breeds->implode('|', 'id'); });
    1 point
  8. I looked up what is set here... folders: 755 files: 644 (config.php 400) Maybe that's too general as well but it seems as those are the only settings - at least I can't find only those permissions here. It matches the details written here: https://processwire.com/docs/security/file-permissions/#permission-755-for-directories-and-644-for-files - so I'm fine with that for now. Whenever I have the feeling I messed to much with those permissions I create a site profile, install it totally fresh and start from there. Doesn't happen that often but it happened. What problems are you facing right now and what errors/warnings show up? Maybe it's something totally different.
    1 point
  9. We haven't accounted for a site-wide count in the API. But you could still do it fairly easily with an SQL query: $result = $db->query("SELECT COUNT(*) FROM field_comments"); list($numTotal) = $result->fetch_row(); echo "<p>There are $numTotal total comments</p>"; $result = $db->query("SELECT COUNT(*) FROM field_comments WHERE status=0"); list($numPending) = $result->fetch_row(); echo "<p>There are $numPending comments waiting approval</p>"; $yesterday = strtotime("yesterday"); $result = $db->query("SELECT COUNT(*) FROM field_comments WHERE created>=$yesterday"); list($numNew) = $result->fetch_row(); echo "<p>There are $numNew new comments posted since yesterday</p>";
    1 point
×
×
  • Create New...