Jump to content

Robin S

Members
  • Posts

    5,009
  • Joined

  • Days Won

    333

Everything posted by Robin S

  1. If a whitelist value is null then it simply means you have not set anything to it at the time you are checking it. Going back to the earlier code example, you must set an array to the whitelist... $san_array = array(); foreach($input->get->st as $st) { $san = $sanitizer->selectorValue($st); $san_array[] = $san; $selector .= "projectStatus=$san, "; } $input->whitelist('st', $san_array); ...before you can use the array in $input->whitelist('st') to determine which checkboxes should be selected. The code above will appear in your search results template, and it must execute before (i.e. above) your code for generating the search inputs. Of course if you are showing your search inputs on other templates besides the search results template then $input->whitelist('st') will be null, but in those cases you don't want any of the inputs to be pre-selected anyway.
  2. You mean you want the pages that are rendered as part of Home to be accessible at /about/, /work/, etc, to human visitors but not to Google? That seems odd, especially if they don't display properly without the CSS/JS from the Home template. I think you do want to prevent direct access to those pages. This thread has some techniques for achieving that:
  3. A little debugging is in order then. You have two variables, $input->whitelist('cb_sectors') and $cb_sectors->name, and you want to know what is in them. You can use basic PHP functions such as var_dump() or print_r(), or you can use the much nicer dumping options in Tracy Debugger.
  4. You could do this as follows: $titles = $page->alias->implode('|', 'title', array('append' => '|')); $titles .= $page->title; $publis = $pages->find("template=publication, categ_publi=$c, author.title=$titles");
  5. You are trying to set the selected attribute of the checkboxes based on $input->get, but typically your search attributes should be set based on $input->whitelist. See the Skyscrapers profile for an example: https://github.com/ryancramerdesign/skyscrapers2/blob/master/includes/search-form.php So you get the whitelist value for the relevant key, which will be an array because that is what you have set to it. Edit: you should first check it with is_array in case nothing has been set to the whitelist yet. And you use in_array against the array for each checkbox value to see if it should be selected.
  6. You are missing an echo statement:
  7. @tpr - I have struck an access problem with Repeaters that seems to be caused by AOS. I opened a GitHub issue for it rather than clutter up this thread.
  8. 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.
  9. 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/
  10. 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
  11. 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(); });
  12. 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); }
  13. 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?
  14. Nice - a really fun feel to the site. But I gotta say the 3D girl falls into the "uncanny valley" for me.
  15. 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.
  16. The PW htaccess only blocks direct access to PHP files inside /site/ Anything outside of /site/ should be accessible.
  17. 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.
  18. A similar topic with some solutions:
  19. @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.
  20. 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.
  21. You pass $page to the render method in the $options array. From the post I linked to above:
  22. 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.
  23. Nope
  24. 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 }
  25. 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
×
×
  • Create New...