Jump to content

Robin S

Members
  • Posts

    5,034
  • Joined

  • Days Won

    340

Everything posted by Robin S

  1. 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);
  2. FieldtypeConcat causes the same error, so that will add to the argument for a core fix.
  3. @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.
  4. @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
  5. Why not use a JS modal to confirm age rather than redirecting to another page? Like this: https://www.vineonline.co.nz/
  6. 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>
  7. 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.
  8. @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.
  9. I've never seen a file at that path before. My sites don't even have a "/wire/config/" directory.
  10. I was just trying to think if there was a way to achieve what I wanted without changes to the module. I saw that the module was adding the import/export features according to a permission so thought I might be able to grant that permission selectively at runtime. But I later realised that the permission is checked at the ready state rather than before the InputfieldTable render so even if my idea was possible I'd have to set the permission at every page load which would be a bit over the top. I think that a couple of extra checkboxes on each Table field config would be ideal - something like "Allow CSV export" and "Allow CSV import", although it would still depend on the user having the relevant permissions so there should probably be a note about that. Existing users of the module would expect to have these options checked on all existing fields and I guess you could deal with that in the module upgrade() method. Thanks!
  11. Hi @adrian, My first time using this module - looks amazing, thanks! (silly me, I've used the awesome import features before) In my site I have a number of Table fields that are used for various purposes, but just one Table field that I want to allow users to export to CSV from. I couldn't see a way to show the export interface just on this one field. Any tips on how I could achieve this? Or would you consider adding a hookable method that would determine if the import/export interface gets added to each Table field? (the relevant permissions would still apply) Thanks. Edit: very minor thing... in AdminThemeUikit there is an outline around the inputfield that has the export iframe and this looks a bit weird. Not sure if there is a better way but I hid it with some custom CSS: .Inputfield_tableExportIframe { outline:none; }
  12. Do these inputfields have a column width set so that they all appear in the same row? If so then I think it is recent core behaviour that collapsing one inputfield in a row collapses all the fields in the row. This didn't use to happen but it did make for some weird gaps and outline anomalies when a single inputfield in a row was collapsed, so the new behaviour is probably better. So if you have an inputfield that will usually be collapsed I think the best thing is to put it on a separate row within the fieldset.
  13. @PascalKonings, the suggestion from @Zeka is probably the way to go, but in case you do want to stick with image tags you can set them dynamically in a hook in /site/ready.php: // Dynamically set the selectable tags for an images field $wire->addHookAfter('InputfieldImage::renderReadyHook', function(HookEvent $event) { /** @var InputfieldImage $inputfield */ $inputfield = $event->object; // The images field $field = $inputfield->hasField; // The page that the field is on $page = $inputfield->hasPage; // Only for a specific images field if(!$field || $field->name !== 'your_image_field') return; $config = $event->wire()->config; $js_name = "InputfieldFileTags_$field->name"; $data = $config->js($js_name); // Set the tags however you like, using $page if needed $data['tags'] = [ 'carrot', 'pumpkin', 'cauliflower', ]; $config->js($js_name, $data); });
  14. I believe so, but the simplest thing would be to try it and see.
  15. The Limit Table module (previously not in the modules directory but I just added it) adds this feature to Profields Table.
  16. Thanks for the suggestion. I'll keep it in mind but for now will leave the interface as it is for a couple of reasons: The intention with this module is just to create a temporary mode to activate when doing a drag sort, and leaving the repeater interface as per the core default at other times. At this point I don't want to get into making broader changes to the repeater interface: hacking controls into the inputfield header (the core doesn't make this easy to do), setting a default view mode, storing the view mode in a cookie, etc, like what is done with image fields. I'm predicting that users will first identify the item they want to drag with the repeater field in its normal mode. When easy-sort mode is activated the repeater items move quite a bit from their original position, and it's a feature of this module that the item you want to drag gets identified with a black background so it's easier to locate. This requires a button per repeater item rather than a single button per repeater field. Fixed in v0.1.1. Although personally speaking I gotta say... I wish @ryan would drop those ancient legacy themes from the core because it's a real hassle for module developers to support multiple themes. The Uikit theme has been the default standard for several years at this point and it's the only theme that's likely to get attention and further development going forward, so PW users should get on board with it. I only test my modules in AdminThemeUikit but will consider compatibility fixes for legacy themes on a case-by-case basis.
  17. Repeater Easy Sort Adds a compact "easy-sort" mode to Repeater and Repeater Matrix, making those fields easier to sort when there are a large number of items. The module also enhances Repeater Matrix by allowing a colour to be set for each matrix type. This colour is used in the item headers and in the "add new" links, to help visually distinguish different matrix types in the inputfield. Screencasts A Repeater field A Repeater Matrix field with custom header colours Easy-sort mode There are two ways to enter easy-sort mode. 1. Click the double-arrow in a Repeater item header. This activates easy-sort mode and also highlights the item with a black background so it's easier to find it in easy-sort mode. 2. Click the horizontal ellipsis icon in the Repeater field header to activate easy-sort mode. To return to normal mode click the vertical ellipsis icon. While in easy-sort mode: The items will reduce in width so that more items can be shown on the screen at once. The minimum width is configurable in the field settings. Any items that were in an open state are collapsed, but when you exit easy-sort mode the previously open items will be reopened. You can drag an item left/right/up/down to sort it within the items. You can click an item header to open the item. An "Exit easy-sort mode" button appears at the bottom of the inputfield. Configuration In the field settings for Repeater and Repeater Matrix fields you can define a minimum width in pixels for items in easy-sort mode. While in easy-sort mode the items will be sized to neatly fill the available width on any screen size but will never be narrower than the width you set here. If desired you can enable easy-sort mode for a field by default. Since easy-sort is then the default mode for the field no "Exit easy-sort mode" button is shown. Use the mode buttons in the field header to change between easy-sort and normal mode when needed. In the field settings for Repeater Matrix you can define a custom header colour for each matrix type using an HTML "color" type input. The default colour for this type of input is black, so when black is selected in the input it means that no custom colour will be applied to the header. Exclusions The easy-sort mode is only possible on Repeater/Matrix fields that do not use the "item depth" option. https://github.com/Toutouwai/RepeaterEasySort https://processwire.com/modules/repeater-easy-sort/
  18. Adapting a post Ryan made in the Repeater Matrix support forum: In /site/templates/admin.php, before the line... require($config->paths->core . "admin.php"); ...add the following... if($page->process == 'ProcessPageEditImageSelect') { // The page ID that is open in Page Edit $edited_page_id = (int) $input->get->edit_page_id; // The page ID that contains the CKEditor field // This is where PW will look for images by default $cke_page_id = (int) $input->get->id; // If the edited page is not the same as the CKEditor page if($edited_page_id && $cke_page_id && $edited_page_id != $cke_page_id) { // Get the CKEditor page $cke_page = $pages->get($cke_page_id); // If the CKEditor page is a particular Repeater field page // Substitute the name of your Repeater template if($cke_page->template == 'repeater_your_repeater_template') { // Set the page ID where you want PW to look for images $input->get->id = $edited_page_id; } } }
  19. @Morphosis, welcome to the PW forums! ? It's unlikely that this is related to browser differences. What's more likely is that you are logged in to the PW backend in Chrome (probably as superuser) but in Safari you are not logged in, or logged in as a less privileged user. So the area to focus on is fields or templates that have access restrictions. If I understand right you have created a Page Reference select field (selectfromrepeater) and set the selectable pages to be items in a repeater field. The template used by a repeater field (named in the format "repeater_[field_name]") is not accessible by non-superusers. The idea is that users should not have direct access to repeater pages but instead must access them via the repeater field value. So if you are defining selectable pages for the selectfromrepeater field using a selector string like this... template=repeater_yourfieldname ...then this will cause problems when a non-superuser works with the field. The "official" way to get repeater pages is via the repeater field value, so you would use the "Custom PHP code" option for defining selectable pages: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if($event->object->hasField == 'selectfromrepeater') { // Get the page that contains the repeater field however suits $page_with_repeater_field = $event->pages->get(1234); // The event return is the repeater field value $event->return = $page_with_repeater_field->repeater_field_name; } }); Technically you could stick with the selector string option and explicitly disable the access control when getting the repeater pages... template=repeater_yourfieldname, check_access=0 ...but in doing that you would be going against the way the core wants you to work with repeater pages, so perhaps better not to do that unless you're 100% clear on all details of how repeater fields work. When debugging issues like this, the Tracy Debugger module is a huge help. The bd() method is all you need to learn to start with.
  20. I think this relates to a problem at the video/Vimeo end rather than a problem with the textformatter module. The post below suggests that the stripes thumbnail is what appears when Vimeo fails to successfully generate a thumbnail for a video: http://support.syngency.com/en/articles/3048197-set-a-new-thumbnail-for-your-video
  21. If you are adding inputfields to a InputfieldForm object (as it looks like you are according the code you posted) then it will work. Yeah, my suggestion is that you don't do that and you instead take advantage of all the useful stuff PW provides for you in the InputfieldForm::processInput() method. This method calls the various processInput() methods of all the inputfields that you have in your form. That does a lot of the input validation work for you and has useful features like inputfield-specific error messages, required fields, required-if logic, etc.
  22. Have you studied this thread? You can use the PW API to process your form submission and then you won't need to do any hacks like that for checkbox fields. The "truthiness" of the checkbox field value once the form has been processed will tell you if it was checked or not. Example: /** @var InputfieldForm $form */ $form = $modules->get('InputfieldForm'); /** @var InputfieldText $f */ $f = $modules->get('InputfieldText'); $f->name = 'greeting'; $f->label = 'Greeting'; $form->add($f); /** @var InputfieldCheckbox $f */ $f = $modules->get('InputfieldCheckbox'); $f->name = 'new_zealander'; $f->label = 'I am a New Zealander'; $f->skipLabel = Inputfield::skipLabelMarkup; $form->add($f); /** @var InputfieldSubmit $f */ $f = $modules->get('InputfieldSubmit'); $form->add($f); if($input->post('submit')) { $form->processInput($input->post); $greeting = $form->getChildByName('greeting')->value; $new_zealander = $form->getChildByName('new_zealander')->value ? 'checked' : 'not checked'; bd("The greeting was '$greeting' and the 'I am a New Zealander' checkbox was $new_zealander"); } echo $form->render();
  23. $field = $modules->get("InputfieldHidden"); $field->attr('name','Name'); $field->skipLabel = Inputfield::skipLabelMarkup; $form->append($field); https://processwire.com/api/ref/inputfield/#pwapi-methods-skipLabel-constants
  24. Well it's not intended for use with Combo but rather with FieldtypeDynamicOptions. But I tested and if you enter paths/URLs to already uploaded Pageimage files as the values of the selectable options then it does work. But I can't see why that would be a better thing to do than using a FieldtypeDynamicOptions field where you can define the selectable options dynamically.
  25. No, but there needed to be some limit set and I can't personally imagine needing more than three custom menus. If anyone using the module finds they need more then I'd consider increasing the limit. Not actual navJSON ajax-loaded menus because those require a Process module. But in the latest version I've allowed for the possibility to define multiple levels of submenus using a hook. See the updated readme. In the hook you can check if the user has or lacks a role and return different child item data accordingly. And in the latest version if you return false from the hook then the menu is not shown at all. See the updated readme. Should be fixed in the latest version.
×
×
  • Create New...