Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/22/2025 in all areas

  1. @snck The issue may be related to the solution I suggested. He didn't respond after my suggestion so it is a good place to start troubleshooting. Please check this first: Please report back if this doesn't fix your issue. @bernhard I've got a hard Friday deadline for a project but as soon as I can get time after that I will work on that improvement. Sorry for the wait, didn't want you to think I forgot about you 👍
    1 point
  2. I see the problem now. It seems weird that ProcessController::isAjax() even exists, tbh. It may be vestigial and can be replaced by $config->ajax, which you could then override yourself in ready.php. But maybe it’s got some vital purpose. I’d say, open an issue about it on Github. Some other options you can implement right now without hacking the core: Just die() public function ___executeCount() { $count = (int)$this->input->post('count'); die($this->renderCountButton(++$count)); } Instead of returning markup from your execute() method, just terminate the request with your desired output. This will skip things like finished.php, so that’s something to be aware of, but it’s probably fine. Just add X-Requested-With public function ___execute() { $this->config->scripts->add('https://cdn.jsdelivr.net/npm/htmx.org@2.0.6/dist/htmx.min.js'); return <<<HTML <div hx-headers='{"X-Requested-With": "XMLHttpRequest"}'> <h2>Hello.</h2> {$this->renderCountButton(0)} </div> HTML; } public function ___executeCount() { $count = (int)$this->input->post('count'); return $this->renderCountButton(++$count); } Make HTMX send the X-Requested-With header. Now you're an ajax request according to ProcessWire. The attribute is inherited, so you can just set it once and forget about it, as in the above example. I have attached a complete module that minimally demonstrates the issue. ProcessHtmxTest.module
    1 point
  3. Hey @bernhard - does everything work as needed if you replace all instances of $config->paths->root on these lines (https://github.com/adrianbj/TracyDebugger/blob/40cfe39239ea1fb2d6ee50920ebc9f3f86b21048/TracyDebugger.module.php#L1058-L1071) with your project root? Or are other changes needed?
    1 point
  4. Custom Inputfield Dependencies A module for ProcessWire CMS/CMF. Extends inputfield dependencies so that inputfield visibility or required status may be determined at runtime by selector or custom PHP code. Overview Custom Inputfield Dependencies adds several new settings options to the "Input" tab of "Edit Field". These are described below. Note that the visibility or required status of fields determined by the module is calculated once at the time Page Edit loads. If your dependency settings refer to fields in the page being edited then changes will not be recalculated until the page is saved and Page Edit reloaded. Usage Install the Custom Inputfield Dependencies module. Optional: for nice code highlighting of custom PHP install InputfieldAceExtended v1.2.0 or newer (currently available on the 'dev' branch of the GitHub repo). The custom inputfield dependencies are set on the "Input" tab of "Edit Field". Visibility Show only if page is matched by custom find Use InputfieldSelector to create a $pages->find() query. If the edited page is matched by the selector then the field is shown. Show only if page is matched by selector As above, but the selector string may be entered manually. Show only if custom PHP returns true Enter custom PHP/API code – if the statement returns boolean true then the field is shown. $page and $pages are available as local variables – other API variables may be accessed with $this, e.g. $this->config In most cases $page refers to the page being edited, but note that if the field is inside a repeater then $page will be the repeater page. As there could conceivably be cases where you want to use the repeater page in your custom PHP the module does not forcibly set $page to be the edited page. Instead, a helper function getEditedPage($page) is available if you want to get the edited page regardless of if the field in inside a repeater or not. $edited_page = $this->getEditedPage($page); Required The settings inputfields are the same as for Visibility above, but are used to determine if the field has 'required' status on the page being edited. https://github.com/Toutouwai/CustomInputfieldDependencies http://modules.processwire.com/modules/custom-inputfield-dependencies/
    1 point
  5. @Christophe, glad you find it useful. Technically you don't need Custom Inputfield Dependencies if you want to show/hide a field according to the parent page ID. The PW core includes a "Parent" field in Page Edit on the "Settings" tab. This field is named "parent_id" so you can do something like this:
    1 point
×
×
  • Create New...