Jump to content

jamienk

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by jamienk

  1. Hm, this feature doesn't seem to be in version 2.2? So the sort order id "date modified" by default? And it can only be changed on a per-child basis?
  2. Hi, From the PW admin, when I create a "new" child page, I'm first prompted to create a 'title' and 'name' before being sent to the fuller template. Can I by-pass this screen? Our "title" and "name" fields are auto-generated based on other field values, so it's a bit confusing to have to type something here... Thanks -Jamie
  3. Solved! Need this: $page = $event->arguments[0]; in the calcMethod function. I suppose that line makes $page contain all the field data... Not sure I understand the $event thing?
  4. I'd greatly appreciate any help in creating such a module. I need a field that gets populated with data parsed from another field. I actually have working code for the frontend, but I think I need it for the backend. I have this simplified code testcase in a successfully loaded module, but it doesn't seem to do anything. I have 2 fields: report_text (type textarea), and report_specialtext (type TextareaSpecial) -- it's meant to grab the contents of report_text, do a simple search and replace, and put the results in report_specialtext: <?php class FieldtypeTextareaSpecial extends FieldtypeTextarea { public static function getModuleInfo() { return array( 'title' => 'TextareaSpecial', 'version' => 100, 'summary' => 'Field that stores some text', ); } public function getSpecialtext($text) { $out=str_replace("search for this", "replace with this", $text); return $out; } public function init() { $this->pages->addHookBefore('save', $this, 'calcMethod'); } public function calcMethod($event) { $text=$page->report_text; $specialtext = FieldtypeTextareaSpecial::getSpecialtext($text); $page->report_specialtext = $specialtext; $this->message("Hello World! Special text {$specialtext}. Normal text: {$page->report_text}"); } } ?> Any help greatly appreciated!
  5. Thanks. I thought "image" was some sort of built-in object -- I didn't realize it was a field with methods based on the "file" type
  6. I've upgraded to PW 2.2 and some of my code has stopped working. I allow my authenticated users to upload pdfs, but I can no longer upload or get the path or url of the uploads. This used to work (edited code to only show the relevent part): $newpage = new Page(); $path=$newpage->images->path; $relpath=$newpage->images->url; Then I save the page with the correct fields filled in. Then I upload the file: $name = strtolower($sanitizer->name($_FILES['upload']['name'])); $file = $path . $name; if(move_uploaded_file($_FILES['upload']['tmp_name'], $file)) { // add it to the page $newpage->report_request->add($file); /// save the page $newpage->save(); } But now $path and $relpath don't return anything. I get the error "Notice: Trying to get property of non-object" which I think refers to images->path and images->url I've tried files->path and files->url (in some of the sample code from these forums I picked up that possibility), but that doesn't work either. How do I access the filesystem path and the url path, both to upload the file and to refer to it? Thank you, Jamie
×
×
  • Create New...