Jump to content

Robin S

Members
  • Posts

    4,791
  • Joined

  • Days Won

    303

Everything posted by Robin S

  1. Some fieldtypes have 'subfields' (not sure if that's the right term exactly). For example, the "Address" field within the Map Marker fieldtype. Is it possible to use setAndSave() to set some subfield of a field? Seems like it should be possible but I can't work out what the right syntax is.
  2. This will require a Javascript solution. Just Google for it and you'll find loads of examples and probably a bunch of ready-made jQuery plugins. Here is something: http://codetheory.in/change-active-state-links-sticky-navigation-scroll/
  3. What form do you mean? A Page Edit form? You could look at these as a starting point: http://modules.processwire.com/modules/form-template-processor/ https://gist.github.com/somatonic/5011926
  4. If it's the title field you want to populate the address from, you could use a hook to set the address when a new page is added. In /site/ready.php: $this->pages->addHookAfter('added', function($event) { $page = $event->arguments('page'); if($page->template != 'my_map_template') return; $page->my_leaflet_map->address = $page->title; $page->save(); });
  5. Right after posting that I started thinking clearly... $inputfield = $event->object; $field = $this->fields->get($inputfield->name); if(!$field) { $name = substr($inputfield->name, 0, strpos($inputfield->name, "_repeater")); $field = $this->fields->get($name); }
  6. I am hooking an inputfield render() method, and I'm hoping to be able to get the $field object that this inputfield is for. I can see the $field object in Tracy but cannot access that directly in the hook. Is there a trick I'm missing? More broadly, my objective is to match the inputfield to its field when the inputfield is rendered inside a Repeater. When the inputfield isn't inside a repeater you can easily work out the field because the name attribute of the inputfield is the same as the field name. But when inside a repeater the name attribute has a repeater suffix appended, e.g. "my_field_repeater1125". The integer at the end is a page ID so that can potentially be any length, and I don't want to do something like trim the name from "_repeater" onwards as someone could conceivably use the string "_repeater" in their field name. Any suggestions?
  7. Nice - a really fun feel to the site. But I gotta say the 3D girl falls into the "uncanny valley" for me.
  8. Do you mean the link for the "Go to this post" button? That isn't encoded for me. BTW, I have seen many requests for fixes and improvements to the forum (and made a few myself) that have, to date, gone unanswered. I wouldn't hold your breath.
  9. The PW htaccess only blocks direct access to PHP files inside /site/ Anything outside of /site/ should be accessible.
  10. That isn't valid syntax for whitelist(). See the docs: https://processwire.com/api/ref/wire-input/whitelist/ The syntax is valid here, but you'll be overwriting the same whitelist key in each iteration of your loop. I think you want to set an array to the whitelist key, e.g. $san_array = array(); foreach($input->get->st as $st) { $san = $sanitizer->selectorValue($st); $san_array[] = $san; $selector .= "projectStatus=$san, "; } $input->whitelist('st', $san_array); // later, call renderPager() with arrayToCSV set false // or do as Ryan suggests: https://processwire.com/talk/topic/1883-how-to-use-input-whitelist-with-checkboxes-or-any-array/?do=findComment&comment=17706 echo $works->renderPager(array('arrayToCSV' => false)); For the other issue regarding setting the selected attribute of the checkbox you'll want to use in_array.
  11. A similar topic with some solutions:
  12. @Mike Rockett, thanks for the info. I asked my host about Let's Encrypt certificates and they said they been providing free SSL certificates for all accounts for the last three months. Must have missed the announcement. Looks like the certificate is by Comodo via cPanel. Not sure what the pros and cons are versus a Let's Encrypt certificate but a check on SSL Labs gave it an "A" so sounds good enough to me.
  13. That sounds great. Who do you host with, and do they publicly promote this on their website? Are they a cPanel host running the Let's Encrypt plugin? Am going to try and convince my host to do the same, and may consider moving host if they won't play ball.
  14. You pass $page to the render method in the $options array. From the post I linked to above:
  15. IMHO this should be the default behaviour of a PageTable field. Having the PageTable pages as children of the page is confusing for editors and I've never understood the reasons why that should happen as the default.
  16. Using render() as kongondo suggests is good - here is some info from Ryan on the available options. But I usually output from a PageTable the same way as I would a Repeater, e.g. if page_table_field is in the "basic page" template, in basic-page.php... foreach($page->page_table_field as $p) { echo "<h3>{$p->title}</h3>"; // etc, for other fields in the PageTable item template }
  17. Any clue how I could start that ? If the module is a Process module you can create and require a custom permission in the module info (that is, getModuleInfo(), etc). See the ProcessHello module for an example: https://github.com/ryancramerdesign/ProcessHello/blob/9c1aa18eb40d069c7fb227f09badddc90f0b3276/ProcessHello.info.php#L33-L39
  18. Another way... adapt this SQL query by Ryan: $table = $fields->get('my_page_field')->getTable(); $query = $database->query("SELECT data FROM $table"); $ids = $query->fetchAll(PDO::FETCH_COLUMN); $count_values = array_count_values($ids); // use the pages IDs and counts as needed, for example: foreach($count_values as $key => $value) { $p = $pages->findOne($key); echo "<p>{$p->title} (selected in $value pages)</p>"; }
  19. There is no built-in method to do this efficiently in PW - to use normal selector queries you would need to iterate over all tag pages, for each tag counting the pages that have that tag selected, then sorting by count. This is one of the things that prompted the Connect Page Fields module
  20. You shouldn't need to do anything special to get pagination to work with search results. Make sure you have page numbers enabled for your search template: Your pagination links (2, 3, 4, etc) should include the GET query string (e.g. "/search/page2?search=foo&year=1985") - do they in your case?
  21. You can do this: $failed_files = array(); foreach($items as $item) { if(file_exists($fileurl)) { $item->scheda_tecnica = $fileurl; $item->save(); } else { $failed_files[] = $fileurl; } } // when finished, echo/log the contents of $failed_files
  22. Hi @Federico, welcome to the PW forums. I'm not really clear about what you're asking but here goes... You want an array of all GET variables? You can get that by using $input->get() without any argument. foreach($input->get() as $key => $value) { // sanitize each $value as needed, etc } But you probably don't want to treat each variable the same, pass it through the same sanitizer, etc. So I think it's more typical to check for the exact named variables you are expecting and ignore anything else that might be there. So for example, for "year" you are expecting an integer so you would apply $sanitizer->inUnsigned(). P.S. take a look at the search template for the Skyscrapers demo - it's a really good demonstration of the basic principles.
  23. That's a namespace problem - for some reason your template is not being compiled with the ProcessWire namespace. You can add the namespace... $comments = ProcessWire\FieldtypeComments::find("comments", $selector); ...but you shouldn't call the find() method statically anyway. The comment block for the deprecated findComments() explains how the find() method should be called: @deprecated Use $field->type->find($field, $selectorString) instead.
  24. I don't know much about GraphQL but I want to learn more, and your module looks like it will make it easy to get started with in PW. So definitely interested.
×
×
  • Create New...