-
Posts
4,928 -
Joined
-
Days Won
321
Everything posted by Robin S
-
Refresh an InputfieldPage element by javascript
Robin S replied to SebastianP's topic in General Support
Yes, that would get tedious with PageListSelectMultiple. But can't you substitute a different inputfield? You say you are using checkboxes in your modal page: checkboxes are an inputfield option for Page Reference fields, so can't you just use checkboxes directly in your Page Reference field? -
You need to initialise/reset the $selected variable in each iteration of the loop. Otherwise two things will happen: 1. If the first child of /sectors/ is not in the whitelist array you will get an undefined variable notice. 2. After one child name is found in the whitelist array and $selected is defined as ' selected ' then all subsequent iterations will output ' selected ', regardless of if that input is in the whitelist array or not. This is the problem you are getting now. So it should be something like: foreach($pages->get("/sectors/")->children() as $sec) { $selected = ''; if(is_array($input->whitelist->cb_sectors) && in_array($sec->name, $input->whitelist->cb_sectors)) $selected = ' selected '; // echo, etc... }
- 21 replies
-
- 1
-
Sounds like a useful thing to have. In terms of UI I imagine something like the action buttons in Page List, where publish/unpublish/hide/unhide buttons appear when hovering the title link in the table. Will investigate how this could be added. Not sure if it's something that belongs in LimitPageTable, or should be a separate module, or perhaps added to AdminOnSteroids. Will have a think.
-
I had a need to do this and there were some requests in the Table forum so... LimitTable A module for ProcessWire CMS/CMF. Allows limits and restrictions to be placed on selected Profields Table fields. For any Table field you can limit the number of rows that may be added and also prevent the use of drag-sorting and the trashing of rows. If a limit has been defined then there is an option to show all (empty) rows up to that limit. This module does not support paginated Table fields. Usage Install the LimitTable module. The module configuration screen should be self-explanatory. You can add rows in the module config as needed using the "Add another row" button. Please note that limits and restrictions are applied with CSS/JS so should not be considered tamper-proof. Module config: The effect of the above config in Page Edit. The empty rows up to the limit are shown because "Show all rows" is checked. https://github.com/Toutouwai/LimitTable https://processwire.com/modules/limit-table/
- 1 reply
-
- 15
-
v0.0.3 released. You can now select multiple roles to be affected by the limit/restrictions, including the superuser role and "all roles".
-
v0.0.9 released. You can now select multiple roles to be affected by the limit/restrictions, including the superuser role and "all roles". @NikNak, I had a change of thinking on this issue and can now see that there are situations when it is useful for the module to affect superusers, mostly to serve as a reminder and prevent accidental changes. In any case a superuser can access the module config and so change any restrictions that are affecting them when needed.
-
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.
- 21 replies
-
- 1
-
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:
-
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.
- 21 replies
-
- 2
-
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");
-
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.
- 21 replies
-
You are missing an echo statement:
-
@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.
-
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.
-
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/
-
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
-
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(); });
-
[solved] Get field from inputfield render hook
Robin S replied to Robin S's topic in Module/Plugin Development
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); }- 1 reply
-
- 3
-
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?
-
Nice - a really fun feel to the site. But I gotta say the 3D girl falls into the "uncanny valley" for me.
-
Forum notification mail: Link to comment in topic invalid (& encoding)
Robin S replied to blynx's topic in General Support
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. -
The PW htaccess only blocks direct access to PHP files inside /site/ Anything outside of /site/ should be accessible.
-
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.
- 21 replies
-
- 3
-
A similar topic with some solutions: