Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/18/2025 in all areas

  1. Hello @Juergen the settings for a custom framework are not working correctly. I am using FrontendForms v2.2.28. I have a tailwindcss.json file in site/assets/files/FrontendForms/frameworks. The Tailwindcss option appears in the Output rendering select field. But when I select it, the output on the frontend uses default classes instead of my tailwind classes. Even if I enter the custom path "site/assets/files/FrontendForms/frameworks" in the corressponding settings field, it doesn't work. If I copy my tailwindcss.json file to site/modules/FrontendForms/CSSClasses it works. Maybe you could look into this issue? Another hint: It would be good to rename the module to .module.php so it get's correct syntax highlighting, and enables static analyzers or Rector to recognize the file. This is also the recommended way of custom modules (don't know where this is mentioned, but I remember reading it). Regards, Jens
    2 points
  2. @Charlie W, you can use an SQL query to match a date column by part of the date, e.g. by month. There are different ways you could incorporate this to find the pages you want, but one simple way is to first get the IDs of all matching pages, regardless of template, published status, etc, and then use those IDs as part of a PW selector. Demo: // First get the IDs of all pages where the month of the date value is February $field_name = 'date'; // The name of your date field $table_name = "field_$field_name"; // The table name is the field name prefixed with "field_" $month_number = 2; // i.e. February, or whatever month number you want to search for $stmt = $database->prepare("SELECT pages_id from $table_name WHERE MONTH(data) = :month_number"); $stmt->bindValue(':month_number', $month_number, \PDO::PARAM_INT); $stmt->execute(); $ids = $stmt->fetchAll(\PDO::FETCH_COLUMN); $ids_str = implode('|', $ids); // Then use the IDs in a selector where you are limiting by template, applying a sort, etc. $items = $pages->find("template=event, id=$ids_str, limit=3, sort=-date"); You can also match a date by just a day number or just a year, e.g. WHERE DAY(data) = :day_number WHERE YEAR(data) = :year
    2 points
  3. In saveReady the page is just about to be saved and therefore output formatting is off, so all image fields (including single image fields) will be a Pageimages array.
    1 point
  4. Thanks a lot @Robin S your code works great. I was trying on saveReady hook too using the below code but couldn't make it work properly. I wasn't using foreach loop as the image field I was testing it accepts only 1 image. $wire->addHookAfter('Pages::saveReady', function($event) { $page = $event->object->getPage(); if ($page->template->name != "my-page-template") return; if($page->image->custom_image_field == "") { $page->addStatus(Page::statusUnpublished); } });
    1 point
  5. @PWaddict, you would need to use a different hook for this because processInput is too early - it happens before Page Edit decides whether the page should be published so any changes to the published status made there would be overwritten. Something like this should work: $wire->addHookAfter('Pages::saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'test_custom_images') { $unpublish = false; foreach($page->images_custom as $image) { if(!$image->text_1) $unpublish = true; } if($unpublish) $page->addStatus(Page::statusUnpublished); } });
    1 point
  6. I have made the entries separated by commas on the installation. I see the fault in the config, the quote/s are wrong. $config->httpHosts = array('dev.my-domain.com,my-domain.com,www.my-domain.com'); I've changed it with the editor. Thanks for the hint!
    1 point
  7. Do you have the domains in the config in an array or as a string? That's how it should look: $config->httpHosts = array('domain.one', 'domain.two', 'domain.three');
    1 point
  8. When I look into the code of the module, there is no way to set “sender_reply” via a function, except via the module config. But there are some Workarounds: Or the easier version via the mail header: $mail->header("Reply-To", "your@replyto.address");
    1 point
  9. Hi @adrian thanks a lot for your answer and yes, it helps a lot and proves that i have to update the module 🙂 very good idea this separate option for the system dates 🙂 the funny thing is that i usualty set the output on non formatted for the date field as well as the system date fields as i onten have to use my own multi language formatting function but in this case i just need a readable "modified" date in the csv as a reminder thanks again for your answer, update in progress within two minutes 😄 have a nice day
    1 point
  10. hi, to be honest when it comes to CKE i tend to use js extra config, for example, in the site/modules/InputfieldCKEditor folder i put a file called config.js with CKEDITOR.editorConfig = function( config ) { CKEDITOR.config.fontSize_sizes = '8/.5rem;10/0.625rem;11/0.6875rem;12/0.75rem;14/0.875rem;16/1rem;18/1.125rem;20/1.25rem;22/1.375rem;24/1.5;28/1.75rem'; CKEDITOR.config.extraAllowedContent = 'section[id,class]'; }; that will define a custom font-size combo list and, just tried and check this one, allows me to add sections with an id and or classes even with ACF on (new for me as i didn't use them before but it was fun to try 😄) but htmlpurifier off as i don't know how to play with its config, i never did... i'(m sure it's quite easy to extend up to whatever else you need to allow
    1 point
  11. Hello @Frank Vèssia! I have replaced size() function with length attribute on Github.
    1 point
  12. I was going to suggest using inputfield dependencies as this would be the simplest option but it turns out there's a problem when using these with custom image fields: https://github.com/processwire/processwire-issues/issues/1889 So here's a hook instead. In this demo I want to show an error message if text_2 is left empty when text_1 is populated. You can adapt the names/labels/logic to your case. $wire->addHookAfter('InputfieldText::processInput', function(HookEvent $event) { $inputfield = $event->object; $field = $inputfield->hasField; $page = $inputfield->hasPage; // Only for an inputfield associated with field "text_2" // Adjust the field name to suit if($field && $field->name === 'text_2') { // Only for an inputfield that is associated with a page using the custom image fields template // Adjust the template name to suit if($page && $page->template == 'field-images_custom') { /** @var InputfieldWrapper $wrapper */ $wrapper = $inputfield->parent; // Get sibling inputfield by label because the name will include a random string // Adjust inputfield label to suit $text_1 = $wrapper->children->get('label="Text 1"'); // Show an error message if text_2 is left empty when text_1 is populated if($text_1 && $text_1->value && !$inputfield->value) { $inputfield->error('A value for "Text 2" is required when "Text 1" is populated.'); } } } });
    1 point
  13. hi guys, i have the following saveReady hook: public function createCodeFile($event) { $page = $event->arguments('page'); if($page->template == 'code' OR $page->template == 'treenode') { // create file if textarea is not empty if($page->code) { $filename = "tmpupload/code" . $page->id . "_" . $page->name . ".inc"; file_put_contents($filename, $page->code); $page->codefile->removeAll(); $page->save('codefile'); $page->codefile->add($filename); unlink($filename); } else { $page->codefile->removeAll(); $page->save('codefile'); } } works great for editing pages, but when i create a new page, i get the error New page '/simple-map/functions/test-test/' must be saved before files can be accessed from it the problem is in the else-block: else { $page->codefile->removeAll(); $page->save('codefile'); } how can i check if "codefile" is accessible? or should i use another hook? if i hooked after "saved" i would have to save the page on my own and that would lead to an endless loop, wouldn't it? thanks for your help!
    1 point
  14. Check for the id of the page. It won't have one before the page is saved.
    1 point
×
×
  • Create New...