Jump to content

Martijn Geerts

PW-Moderators
  • Posts

    2,769
  • Joined

  • Last visited

  • Days Won

    31

Everything posted by Martijn Geerts

  1. BFD Calendar, nothing is save. If a page is deleted your ID will be gone to. Eventually it's better to stick with name, cause that can be re - created easily, not that id. WYSIWYG is a dirty thing. When programming, you can link pages with relationship with WYSIWYG you can't. ( without loads of overhead )
  2. Big thanks for the update & the code_formatting thing !
  3. Cool, tnx for the response. I Can imagine I gonna build some kinds of fieldtype from this. Because you've got some valid points about this. The lastline "Technically there's also a way to add a runtime value to a pages that is used in selector on page arrays." I don't fully understand.
  4. yep: Dirty: not#$#%=tralala, body=soma, title|headline%=start, also_not_available=test Cleaned: body=soma, title|headline%=start You could use it like: $dirty = 'not#$#%=tralala, also_not_available=test'; $cleaned = returnValidSelector( $dirty ); // empty string if($cleaned) $pages->find($cleaned); // never executed --- $dirty = 'not#$#%=tralala, also_not_available=test, title=Soma'; $cleaned = returnValidSelector( $dirty ); // title=Soma if($cleaned) $pages->find($cleaned); // no errors, valid selector, search pages
  5. In a page I have a field that i want to use as a selector string. I want the dirty string to be cleaned ( strip out all invalid parts ). So processWire will never throw an error. This is what I came-up with, but there must be a better way. /** * Clean a Dirty selector string * @param (string) $string, Dirty ProcessWire selector string. * @return (string) Cleaned ProcessWire selector string. */ function returnValidSelector( $string ) { $out = ''; if(strlen($string)) { $exclude = array(); $explode = explode(",", $string); foreach ($explode as $value) { $value = trim($value); if(!Selectors::stringHasSelector($value)) continue; // string or array if(preg_match('/^(!?[_|.a-zA-Z0-9]+)(.*)/', $value, $matches)) { $field = trim($matches[1], '|'); $field = strpos($field, '|') ? explode('|', $field) : $field; } if(is_string($field)) { if(wire('fields')->get($field)->id) $exclude[] = $value; continue; } if(count($field)) { foreach($field as $f) { $goodField = wire('fields')->get($f)->id; if(!$goodField) break; } if($goodField) $exclude[] = $value; } } $out .= implode(", ", array_filter($exclude)); } return $out; }
  6. I'm on a project which can grow quickly. I used ProcessDateArchiver (wonderful module) to automagiclly put pages a folder, (year/month/day/) This way the lists are never to big to browse. If that is not an option, maybe you can make a some kind of text formatter that most of the linking does for you. I know, those 2 are not easy options,
  7. @saml, what I usually do is: 01. Instal ProcessWire. 02. Delete unwanted pages. 03. Leave fields as they are. 04. Leave templates as they are. 05. Rename Fields & Templates when needed. 06. You'll see that you'll reuse every single template & field.
  8. Fieldtype File from folder I “needed” a module to select a file from a folder, using an <select> and store the filename. There's only 1 setting: The path to the folder to list. The Path is relative to the templates directory. So if your files are located in /site/templates/scripts/, type scripts/ in the `path to files` setting. here's the gist, enjoy. This module is released because it was useful for me in several projects.
  9. @Soma: feature request Remove Indentation, not rendering tabs newlines & other unnecessary white-space characters. Lot's of time, ill remove them with regex, but hey, i'm lazy...
  10. They should use .bmp for the logo!
  11. That's cruel. Don't they have any respect !
  12. Output formatting on the field is better that breaking compatibility. Thanks Soma, you've done the right thing.
  13. offtopic @Soma, break compatibility would make your color picker better. Now your field always need some extra logic. You can't just output $page->color, because of the max length of 6 characters. example: "<div style='color: #{$page->color};'>"; can render to <div style='color: #transp;'> I do love this field, but the extra logic sucks. Please break the backward compatibility.
  14. Take a look at ryan's example, it's basic but works.
  15. Congratulations ! Onjegolders & Diogo Site's looking great, hope the same for the business !
  16. No issues here, the Netherlands
  17. Do you have somewhere else a search on the page for the same pages ? If thats true, try to add start=0 to the other find calls.
  18. Don't use continue in that loop !
  19. That also possible as long as those templates have the same fields. But that needs some custom code.
  20. With ASM it will work as good as this way with radios. But there's use case for the radio option in a project I'm working on right now. Showing all options at first sight clarifies what the field does more then using the ASM route.
  21. Add de-select option to single page select using radio buttons. The problem I have the following structure: home | |-- car | `-- bike I want to have a Pagefield with radio buttons, select cars or bikes or nothing. But when you select one option, you can't deselected it. You could however solve this with a third page in the tree and name it “I don't travel”, but that doesn't make any sense. home | |-- car | |-- bike | `-- I don't travel <-- we don't want that, makes no sence A Solution 1. create a field with the type of page, name transport for example. 2. on the "details tab" select: Single page (Page) or empty page (NullPage) when none selected 3. under the input tab go to: Custom PHP code to find selectable pages 4. type: // deselect page $deselect = new Page; $deselect->parent = $page; $deselect->name = 'unused'; $deselect->template = 'basic-page'; // need to be a available template $deselect->title = "I don't travel"; // pagearray with cars and bikes $transport = $pages->find("parent=1, template=basic-page"); // change title used for radio button (if wished) foreach($transport as $vehicle) { $vehicle->title = "Travel by: " . $vehicle->title; } // empty pagearray, used for returning $array = new Pagearray(); // fill the array $array->import($transport); $array->add($deselect); return $array; 5. save it Now, add this field to your template. On pages using this template you can now select Travel by: car or Travel by: bike or “I don't travel”. The following radio options appear at the field: // radio button options shown in the field ( ) Travel by: Car ( ) Travel by: Bike (•) I don't travel <-- default value, Nullpage If “I don't travel” is chosen, the field returns a Nullpage, you could check it with $page->transport->id === 0. If there's nothing chosen, the radio button for “I don't travel” is pre selected, as that radio has no value. ( Post edit: clarifying the example )
×
×
  • Create New...