-
Posts
5,039 -
Joined
-
Days Won
340
Everything posted by Robin S
-
is pw 2.7.3 not compatible with mysql 5.7.12?
Robin S replied to adrianmak's topic in General Support
Just a guess: there might be a setting in sql_mode that PW doesn't like. Maybe NO_ZERO_DATE or NO_ZERO_IN_DATE - I'm not sure what the PW requirements are regarding sql_mode settings. -
Is this a container page that holds multiple blog posts? If so $page is likely to be the container page, not the blog post page. In your loop that iterates the blog posts you would replace $page with whatever variable you have assigned to a single iteration. Something like: $posts = $pages->find("template=blog_post"); foreach($posts as $post) { // output post content here... if($user->hasPermission('page-edit', $post)) { // output edit link here... } }
-
Need help to create my own Fieldtype
Robin S replied to kreativmonkey's topic in Module/Plugin Development
Are you looking to create a Fieldtype module to get a job done, or more as a learning exercise? If it's the former and you place a value on your own time you will probably come out ahead by purchasing the ProFields package. I don't follow exactly what you are wanting to do but I think Table could be suitable, or possibly Multiplier or Textareas. If it's more of a learning exercise then you can expect this to be somewhat challenging, but you have the Events modules as a starting point. Why do you say that the code for the Events modules does not help you? The code is well commented and it sounds like you want to do something quite similar to what the Events modules do. -
It's not unusual to hear of a website moving from WP to PW but this is the first time I've heard of one going the other way. Call me crazy, but I thought a business that wants us to believe they are qualified to pass judgement on the software used to develop websites might be capable of doing their own website development and customisation in-house.
-
And you'll probably want to add something to make sure you only match pages containing my_repeater: $pages->find("my_repeater.count>0, !my_repeater.my_checkbox<1");
-
Available module functions and variables
Robin S replied to benbyf's topic in Module/Plugin Development
You're not the first person to say this so there must be something to it, but that is not my experience. As a PW learner I haven't found working with modules to be a lot more difficult than working with any other aspect of PW / PHP and the docs seem pretty good to me. My experience has been that module development is challenging, but in a good way - you just get stuck in, debug issues as they arise, and ask for help in the forums when you get stuck. This makes me wonder if you are holding back from actually starting on your module while you do 'research' - I'm not sure this is the best way to learn module development and my suggestion is just make a start and learn as you go. Like many things in PW, I think you'll find it's a lot simpler and easier than you anticipate when you're on the outside looking in. Part of the problem with providing detailed documentation for something like module development is that the subject is so broad - a module can be created for any purpose and whoever is writing the docs can't know what you might want to do in your module. By analogy, it's like if you are learning to cook: you won't find much if you are searching for documentation on how to cook in general because the topic is too broad. Instead you have to decide what you want to cook and then look for help with that - how to make a chocolate cake or how to pluck a goose. Maybe you can say a bit about what you want your module to do? -
It should be fine to use repeaters for what you want to do. Do you mean Javascript errors or PHP errors? If it's a JS problem then have a look for documentation or examples for using multiple galleries with whatever gallery script you have chosen. For example: http://www.menucool.com/1075/Add-multiple-sliders-to-one-page
-
Echoing a comment from Matjazp on the blog: it would be great to hear how these traversal problems were solved. Maybe we could have a blog post some time that takes an advanced programming challenge like this, or the findMany() method introduced in 3.0.19, and walks through the process of how it was approached. The initial problem/challenge, the hypothesis of how it could be solved, any missteps or changes in direction that happened along the way, and the resolution. It would be super-interesting to learn how you tackle these things!
-
Does clearing the cache for ProCache help? The reason I suspect ProCache is that... http://ukmoths.org.uk/thumbnails/crambidae ...exhibits the weird links but when a get variable is appended that would bypass ProCache the links are normal. http://ukmoths.org.uk/thumbnails/crambidae?foo=bar
-
Available module functions and variables
Robin S replied to benbyf's topic in Module/Plugin Development
You have the whole API available to you for module development. The examples above are not specific to modules, but are methods of the Wire class. https://processwire.com/api/ref/wire/message/ https://processwire.com/api/ref/wire/error/ My go-to pages for module-specific info are: https://processwire.com/api/ref/module/ https://processwire.com/blog/posts/new-module-configuration-options/ -
Deleting fields directly from the field list
Robin S replied to Juergen's topic in Wishlist & Roadmap
Sounds like a job for the API Delete fields by name: <?php $field_names = ['field1', 'field2', 'etc']; foreach($field_names as $field_name) { $field = $fields->get($field_name); $fields->delete($field); echo "Deleted field '{$field->name}'<br>"; } Or maybe delete all unused fields: <?php foreach($fields as $field) { if( count($field->getFieldgroups()) === 0 ) { $fields->delete($field); echo "Deleted field '{$field->name}'<br>"; } } Or you could make a form displaying checkboxes for each unused field and select which to delete, similar to what @diogo does here for templates. -
Glad you got it working. The sub-selector docs are here but I'm sure you found them by now.
-
Thanks for the info. Seems that this affects all new map applications and existing applications (like mine) are grandfathered.
-
If you mean the message in your browser console I think it's just a warning rather than an error. I'm using the Map Marker module without an API key and it's working fine.
-
Maybe $pages->getById() is the way to go. $my_pages = $pages->getById([1086,1021,1053,1018]);
-
Here is another way you can get your repeater items, by first finding the pages those repeaters are on. Not tested. <?php // sanitized input $types = $sanitizer->selectorValue($input->get->type); $patterns = $sanitizer->selectorValue($input->get->pattern); $designers = $sanitizer->selectorValue($input->get->designer); $colours = $sanitizer->selectorValue($input->get->colour); // selector $selector = "template=template_with_repeater_field, collections_detail_images.count>0, sort=title"; if ($types != "all") $selector .= ", collections_detail_type=$types"; if ($patterns != "all") $selector .= ", collections_detail_pattern=$patterns"; if ($designers != "all") $selector .= ", collections_detail_designer=$designers"; // here we make sure we only find pages that have the right colour in one of their repeater items if ($colours != "all") $selector .= ", collections_detail_images=[collections_detail_image_colour.collections_colours_group=$colours]"; $results = $pages->find($selector); include './collections-filters.inc'; // not sure what this does ?> <?php if(count($results)): ?> <div class="container-fluid"> <div class="row"> <div class="fabric-list-container collections-results all"> <?php foreach($results as $result) { $fabrics = $result->collections_detail_images; $fabrics->sort("collections_detail_image_colour"); if($colours != "all") { $fabrics->filter("collections_detail_image_colour.collections_colours_group=$colours"); } foreach($fabrics as $fabric) { include './fabrics-list.inc'; } } ?> </div> </div> </div> <?php endif; ?> Another thought: seeing as you want to do all this stuff with your repeater items outside the context of them being fields in another page maybe repeaters are not the ideal mechanism for your data. Could these repeater items instead be normal pages, related to their 'get-for' pages either via a parent-child relationship or via a Page field in the collections_detail_images pages? You can make the collections_detail_images pages easy to add by including them in the "Add New" menus.
-
Maybe I'm not understanding you right, but can't you search for pages that contain the repeater fields and then get the repeater items for those pages? I think (based on the code you showed in this thread) that the fields you are filtering and sorting on are fields in the get-for page rather than fields that are necessarily inside the repeater items so it seems like what you want to be finding are the get-for pages. Another general idea that might be useful: if you look at the page structure around repeaters in the Admin section of the tree you see that the repeaters parent name is "for-page-1234" where 1234 is the id of the page the repeater is on. So if you want to search for repeater items directly with a $pages->find() you could first construct an array of parent page names to use in the selector. Something like: <?php $get_for_ids = $pages->find("foo=bar")->each("id"); $parent_names = array_map( function($item) {return "for-page-$item";}, $get_for_ids ); $parent_names = implode('|', $parent_names); $repeater_items = $pages->find("template=repeater_my_repeater, parent.name=$parent_names");
-
bug addHookAfter and image drag/drop on repeater causing issues
Robin S replied to a-ok's topic in General Support
See the screenshots below for a demo of how the Inputfield Selectize module can be used with getForPage()... Page with repeater field Page field using Inputfield Selectize Page field options (note: I'm recycling an existing 'headline' field as the attribute in the repeater) Edit: I'm a big fan of the new Inputfield Selectize, but if you want to use one of the other Page inputfields then have a read of this post - you'll see how the code could be adapted to use getForPage(). -
I don't have much experience with the PW3 front-end editing features, but this seems to work: <?php $heading_field = $page->headline ? 'headline' : 'title'; $content .= "<h1>$page->edit($heading_field)</h1>";
-
I think your question relates more to how PW sorts PageArrays created via find() rather than Hanna Code specifically. I guess you are doing something like this in your PHP: $my_pages = $pages->find("id=1086|1021|1053|1018"); I was surprised to discover, as you did, that the resulting PageArray does not sort the pages in the order the IDs were given. This is what I came up with as a workaround: $my_ids = [1086,1021,1053,1018]; $my_pages = new PageArray(); foreach($my_ids as $id) { $my_pages->push($pages($id)); } I'd be keen to hear if there is a better way to get pages into a PageArray while maintaining a given order of page IDs.
-
bug addHookAfter and image drag/drop on repeater causing issues
Robin S replied to a-ok's topic in General Support
Ah, I see. If these values are being stored only for the purposes of displaying in the Page inputfield you could combine them into a single field in the repeater. Or potentially avoid the need for this hook by using the Inputfield Selectize module: -
bug addHookAfter and image drag/drop on repeater causing issues
Robin S replied to a-ok's topic in General Support
This isn't a direct answer to your issue, but do you actually need this hook? It looks like you want each repeater item to store some values from the page the repeater field is on (the "for-page"), but this seems like unnecessary duplication. Can't you just get the values from the for-page once and output it wherever needed? If you want the value from inside a loop that is outputting repeater items you can use getForPage(), but chances are you already have the for-page in another variable (e.g. $page). So in your template: <?php $type = $page->collections_detail_category->name; // similarly for other values foreach($page->collections_detail_images as $collections_detail_image) { // do what you want with $type, and any other repeater item fields } -
Not sure this is the right place to report this, but I noticed that the "Related Forum Threads" links in the documentation for the Images fieldtype are broken.
-
I think you want <img src="<?php echo $config->urls->templates ?>images/b1.jpeg"> or with short syntax <img src="<?= $config->urls->templates ?>images/b1.jpeg"> And to be honest, I usually hard code the paths to my template images. <img src="/site/templates/images/b1.jpeg">
-
That would be a nice feature. I'm a strong believer in the benefits of minimising mouse usage. In the meantime... I'm not sure if this is a Windows or a Firefox thing, but if I click the select box and then start typing the highlight moves accordingly. So it's almost like an autocomplete. One catch is that you can't see the highlight on disabled items (i.e. those fields that are already added to the template) but you can type a letter or two and then use the arrow keys to complete the selection.