Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. I see what you mean. It does seem like a bug that Ryan should take a look at. Edit: GitHub issue opened. https://github.com/processwire/processwire-issues/issues/1482
  2. In your template file: if($input->get('print')) { // Your special print-friendly markup here } else { // Your normal markup here } In your normal markup include a link to the print-friendly view: <a href="<?= $page->url ?>?print=1">Print-friendly view</a> If you want to automatically open the browser's print dialog you can include this in your print-friendly markup: <script> window.print(); </script>
  3. I don't think $event->replace = true is supposed to have any effect on whether an "after" hook fires for a method - it just means that the code inside the hooked method will not execute. If you're trying to stop subsequent hooks from firing then have a look at $event->cancelHooks (https://processwire.com/api/ref/hook-event/)
  4. I suggest checking that the PHP extensions and settings are the same between your PHP 7.4 instance and your PHP 8 instance. For example, someone posted recently with the same issue and found that the problem was due to unexpected settings in php.ini
  5. I can confirm this. It's like the order of the field names is treated as if they are in order of priority, but I don't think this is expected - all the fields in the OR condition should be treated equally. Could you please open a GitHub issue so Ryan is alerted? https://github.com/processwire/processwire-issues/issues
  6. A few suggestions: 1. It's best to match using a page's ID rather than its name, because the ID is globally unique but the name is not. So instead of... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page->name") ...you can do... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page->id") ...and because the string value of a Page object is its ID it's typical to do... $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page") 2. You don't need to create a PageArray and add pages to it because $pages->find() already returns a PageArray. So this... $techniques = new PageArray(); $selector_tech = "template=Technique, relation_technique_substance.relation_technique_substance_select=$page->name"; $techniques->add($pages->find($selector_tech)); ...can be simplified to... $techniques = $pages->find("template=Technique, relation_technique_substance.relation_technique_substance_select=$page"); 3. PageArrays have a count() method/property, so rather than... if (sizeof($techniques) > 0) { ...try... if ($techniques->count) { 4. To answer your main question, the value of a Repeater field is a (Repeater)PageArray so you can use ->find($selector) to search within it. foreach ($tech->relation_technique_substance->find("relation_technique_substance_select=$page") as $relation_technique_substance) { Now any Repeater items where relation_technique_substance_select does not include $page will be excluded.
  7. It's working inside a Repeater for me. This module works via JavaScript, and only with the inputfield. You're showing an SQL error but this module won't be anything to do with that. If a totally different inputfield is also affected then it's unlikely to be anything to do with this module.
  8. I think I've found a fix for this. Please update to v0.3.3 and let me know if that version resolves the issue for you.
  9. You would need to edit the module to add the permission settings in the getModuleInfo() method or equivalent "info" file. You can refer to Ryan's ProcessHello module as an example: // name of permission required of users to execute this Process (optional) 'permission' => 'helloworld', // permissions that you want automatically installed/uninstalled with this module (name => description) 'permissions' => array( 'helloworld' => 'Run the HelloWorld module' ), If you want the permission to be automatically installed you would need to uninstall and then reinstall the module.
  10. Thanks to @monollonom in v0.2.5 you can now use the module to add files/images to fields using the API. From the updated readme: A addFromUrl method is also added to the API to achieve the same result. The argument of this method is expected to be either: a URL: "https://domain.com/image.jpg" an array of URLs: ["https://domain.com/image1.jpg", "https://domain.com/image2.jpg"] Example: $of = $page->of(); $page->of(false); $page->file_field->addFromUrl("https://domain.com/path-to-file.ext"); // No need to call $page->save() as it's already done in the method $page->of($of); Should you have an issue using the method, please have a look at the "errors" log to check if something was wrong with your URL(s).
  11. Welcome to the PW forums ? PW doesn't currently provide a way to find pages by the length of a field value. Although I think it would be a nice feature so I took the liberty of opening a request: https://github.com/processwire/processwire-requests/issues/424 Technically you could achieve it with a custom SQL query: $sql = 'SELECT pages.id FROM pages LEFT JOIN field_title ON field_title.pages_id = pages.id WHERE CHAR_LENGTH(field_title.data) > 10 AND pages.templates_id != 2 AND pages.parent_id != 2 AND pages.parent_id NOT IN (SELECT pages_id FROM pages_parents WHERE parents_id = 2 OR pages_id = 2)'; $ids = $database->query($sql)->fetchAll(\PDO::FETCH_COLUMN); $results = $pages->getByIDs($ids); But you might find it simpler to stick with what you're already doing.
  12. Check that the "Inputfield column widths" setting in the AdminThemeUikit module config is the same before and after the upgrade. If you want to avoid the JS-set widths then I think you want the "Uikit uk-width classes" option.
  13. As a general rule (not related to PW specifically), when you see an inline style in the DOM it's almost always an indication that the style was added by JavaScript. It's not because somebody has some preference for inline styles as such. So if you see an inline style in the PW admin it's probably because the style needs to be set dynamically by JavaScript (or needed to be at the time the admin theme was authored). No doubt. But some of the bundled PW admin themes pre-date widespread browser support for flexbox. And fully overhauling a legacy admin theme would be huge job that I expect is not a major priority for Ryan. I haven't seen this in AdminThemeUikit, which is the most recently added core theme. If CSS3 features like flexbox are important to you then this is the admin theme you want to be using.
  14. I guess you could exclude pages that are in the trash by changing... $referenced_on = wire('pages')->find("$pr_fields_str=$page->id, include=all"); ...to... $referenced_on = wire('pages')->find("$pr_fields_str=$page->id, include=all, status!=trash");
  15. Thanks for tackling this project! If the rrule for an event doesn't need to be searchable via $pages->find() then you could store it in $page->meta() and use the standard field table for the event occurrences. And if there really was a strong need to find event pages by rrule then you could add a custom search method that queries the pages_meta table.
  16. I think you must have some other bug in your code. When doing $some_pagearray->add() this is WireArray::add() and the argument can be a single item or a WireArray of items. So there shouldn't be any problem adding multiple pages to the PageArray like this. My two "basic_page" pages with colours in a "multiple" Page Reference field: And you can see the result: By default a Page can only exist once in a PageArray so you'll notice that the "Orange" page is not duplicated in the PageArray despite being selected on both pages. The order of colours looks a bit random but you can apply whatever sort you want by doing something like... $colours->sort('title'); ...or... $colours->sort('sort'); ...before the PageArray is output in your template.
  17. When adding/saving Repeater items the sort order is determined by the "sort" value of each Repeater page, not by any order you might apply to the Repeater PageArray. An explanation of sort values is here. You could use the $pages->sort() method to set the sort value of the Repeater page you're adding and it will automatically update the sort values of the sibling Repeater pages. $thatPage->of( false ); $newItem = $thatPage->my_repeater->getNew(); $newItem->foo = 'bar'; $newItem->save(); $thatPage=>my_repeater->add( $newItem ); $thatPage->save(); // Set the sort value of the new item to 0 and adjust sibling sort values $pages->sort($newItem, 0);
  18. FieldtypeConcat causes the same error, so that will add to the argument for a core fix.
  19. @adrian, it might be that every Fieldtype needs to create a table in the DB regardless of if it is used or not. For instance, FieldtypeFieldset creates a table that is never used. FieldtypeRuntimeOnly originally did create a DB table because I based it on FieldtypeFieldset, but later versions prevented the table from being created after a pull request from you. You could open an issue on the PW repo to see if Ryan will add a check in findRaw for fieldtypes that do not have a corresponding table, but if he's not willing I think the only fix will be to go back to creating a table for FieldtypeRuntimeOnly fields on field creation.
  20. @Ksenia, I read your post a few times but I'm not sure I understand what you're trying to do. A couple of things that might help... 1. The space after the equals sign in the selector here is wrong: $selector_ind .= ", relation_individual_technique.relation_individual_technique_select= $selected_technique"; It should be: $selector_ind .= ", relation_individual_technique.relation_individual_technique_select=$selected_technique"; 2. If you're trying to get a PageArray of organisations, and those organisations are referenced in a Page Reference field in individual pages then you can do something like this: // A new empty PageArray that will hold the organisations selected for all the individuals $organisations = new PageArray(); // The $individuals PageArray has been created elsewhere in your code foreach($individuals as $individual) { // Add to $organisations from the "organisations" Page Reference field $organisations->add($individual->organisations); } // Now do something with $organisations
  21. Why not use a JS modal to confirm age rather than redirecting to another page? Like this: https://www.vineonline.co.nz/
  22. Welcome to the PW forums! A URL segment is suitable for a single tag but not for multiple tags. The simplest way to submit multiple tags is via checkboxes in a form. If you want a different appearance (e.g. something that looks more like buttons instead of checkboxes) then once you have the basic form working you could hide the checkboxes with CSS and show some buttons that check/uncheck the hidden checkboxes using JavaScript. This is a generic example but you can adapt it to your scenario... At the top of your template file: // Get your tag pages $tags = $pages->find("template=tag"); // Get the array of tags that the user has submitted via the form $selected_tags_raw = $sanitizer->array($input->get('tags')); // Sanitize the tags against the valid tags $selected_tags = $sanitizer->options($selected_tags_raw, $tags->explode('name')); // Build up a selector string $selector = "template=document"; // Add the selected tags to the selector string - these will use AND logic foreach($selected_tags as $selected_tag) $selector .= ", tags=$selected_tag"; // Find the matching pages and later output them wherever you need $matches = $pages->find($selector); And later in the template file markup where you want the form to appear: <form action="./" method="get"> <?php foreach($tags as $tag): ?> <?php $checked = in_array($tag->name, $selected_tags) ? ' checked' : '' ?> <label><input type="checkbox" name="tags[]" value="<?= $tag->name ?>"<?= $checked ?>> <?= $tag->title ?></label><br> <?php endforeach; ?> <button>Submit</button> </form>
  23. I'm not sure if I'm a typical user, but I would only want the import/export features on fields where I've specifically enabled them, and doing it that way would mean I have to remember to disable the import/export any time I add a new Table field. If nobody has mentioned this need until now maybe it's quite rare and hookable methods would be enough for those who need it? In the short term I edited the module and added... public function ___allowExport(InputfieldTable $inputfield) { return true; } ...and near the top of TableCsvImportExport::buildTableExportForm()... if(!$this->allowExport($event->object)) return; ...and in my ready_admin.php... // Only show Table CSV export option on selected tables $wire->addHookAfter('TableCsvImportExport::allowExport', function(HookEvent $event) { $inputfield = $event->arguments(0); $field = $inputfield->hasField; if(!$field || $field->name !== 'plant_votes') $event->return = false; }); So one option would be to add something like this for both import and export options, and people who need it can use hooks to do tests on field, page, user, etc and return false whenever they don't want the import/export features to be available.
  24. @adrian, could you please open a GitHub issue or raise this in the RuntimeOnly support thread? I'd like to confirm a few details but don't want to take this thread off-topic.
×
×
  • Create New...