Jump to content

hellomoto

Members
  • Posts

    355
  • Joined

Everything posted by hellomoto

  1. Or the repeater subfields could be added to the select list for the field connections directly... that would simplify the importPageValue part. But still... if I do /** * Build the "Step 2" form to connect the fields * */ protected function buildForm2() { $form = $this->modules->get("InputfieldForm"); $form->method = 'post'; $form->action = './'; $form->description = "Step 2: Connect the fields"; $form->value = "Below is a list of fields found in your CSV file. " . "For each of them, select the field it should import to. " . "Leave any fields you want to exclude blank. " . "Once finished, click 'Start Import' at the bottom of this page. " . "Note: any field names in your CSV file that match those in your site " . "will be automatically selected."; $fp = fopen($this->csvFilename, "r"); $data = fgetcsv($fp, 0, $this->session->csvDelimeter, $this->session->csvEnclosure); foreach($data as $key => $value) { $f = $this->modules->get("InputfieldSelect"); $f->name = "csv" . $key; $f->label = $value; $f->addOption(''); foreach($this->template->fieldgroup as $field) { $valid = false; foreach($this->fieldtypes as $ft) { if($field->type instanceof $ft) { $valid = true; break; } } if(!$valid) continue; if($field->type instanceof FieldtypeRepeater) { echo count($field->repeaterFields); foreach($field->repeaterFields as $item) { echo wire("fields")->get($item)->name . '<br/>'; //$label = wire("fields")->get($item); //$label = $item->name; //$f->addOption($item->name); } } $label = $field->name; $f->addOption($field->name, $label); if($field->name == $value) $f->attr('value', $field->name); } $form->add($f); } fclose($fp); $this->addSubmit($form, 'Start Import'); return $form; } That returns 8 for count($field->repeaterFields), which is correct. Yet, executing the next foreach statement echoes 23 iterations of name of each subfield. For example: repeater field = "engines", its repeaterFields = ["engine_field1", "engine_field2", "engine_field3", "engine_field4", "engine_field5", "engine_field6", "engine_field7", "engine_field8"] and each of those are echoed out together -- 23x. Should just be once, for a total of 8 lines, not 184...
  2. Resources (Ryan's own): ImportPagesCSV FieldtypeMapMarker So I edit the accepted $fieldtypes on :76: /** * List of Fieldtypes that we support importing to * */ protected $fieldtypes = array( 'FieldtypePageTitle', 'FieldtypeText', 'FieldtypeTextarea', 'FieldtypeInteger', 'FieldtypeFloat', 'FieldtypeEmail', 'FieldtypeURL', 'FieldtypeCheckbox', 'FieldtypeFile', 'FieldtypePage', 'FieldtypeMapMarker', 'FieldtypePassword', 'FieldtypeRepeater' ); Page, MapMarker, Password and Repeater were added by me. Then alter importPageValue: /** * Assign a value to a page field * */ protected function importPageValue(Page $page, $name, $value) { $field = $this->fields->get($name); if($field->type instanceof FieldtypeFile) { $value = trim($value); // split delimeted data to an array $value = preg_split('/[\r\n\t|]+/', $value); if($field->maxFiles == 1) $value = array_shift($value); $data = $page->ImportPagesCSVData; $data[$name] = $value; $page->ImportPagesCSVData = $data; } elseif($field->type instanceof FieldtypePage) { $value = trim($value); if(wire("pages")->find("$name=$value")) $page->set($name, $value); } elseif($field->type instanceof FieldtypeMapMarker) { $value = trim($value); $page->set($name->address, $value); } elseif($field->type instanceof FieldtypeRepeater) { // } else { $page->set($name, $value); if($name == 'title') $page->name = $this->sanitizer->pageName($value, 2); // Sanitizer::translate elseif($name == 'fullname') { $page->name = $this->sanitizer->pageName($value, true); } } } Page import works with ID values, which was trivial to incorporate; passwords too. MapMarker and Repeater as you might guess do not. How can I save the map->address value? Hopefully it will update the corresponding map fields too but one thing at a time. As for the repeaters... LostKobrakai tipped me off to foreach($page->engines as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } which works for their names and values, but in this function you're passed the field, and something like foreach($page->$field as $e) { foreach($e->fields as $field) { echo $field; echo $e->get($field); } } doesn't work... and what it would need to do inside anyway is check for a subfield whose name is equal to the column header (choose the repeater field itself e.g., engines in the select per repeater subfield value, e.g., engine_fueltype), then explode that cell value by pipes ('|'), and for each subvalue, populate the repeater#->subvalue... but before all that I need to be able to iterate through the subfields from the field in this function. Anyone have any ideas?
  3. I'm working with a PW 2.5.3 install. Here http://processwire.com/blog/posts/processwire-core-updates-2.5.14/ there is a quick tutorial on setting up an alternate user template and parent. I followed it to the T, but it didn't work; when adding a new user, there was no choice of template, and once the user was created the alternate template I had set wasn't even among the select options. Has anyone managed to do this or even just an alternate template successfully? The alt. tpl. is what I rly. need... I just tried it twice over and then erased and undid everything 2x too, so... Then I only unchecked "Don't allow pages to change their template?", cloned user template (id=75), added "$config->userTemplateIDs = array(3, 75);" to config.php created a new user No alternate template option still. This should be able to work right? Because I don't see a date for that blog post but do only see comments from 5 days ago, but it says 2.5.13, I'm using 2.5.3.
  4. I follow the instructions exactly and when I add a new user, there's only the name field, not template, and once I enter a name and create, go to Settings tab, the one I have set for the alternate user tpl doesn't appear in the list. What a shame.
  5. Of course! I have to use include=all for other things already (like field options for public pages, which themselves are hidden)... man. Thank you. Okay, so that I did and it works as expected. However, since posting this thread I did go ahead and try the alternate user template/parent example given in that blog post I linked, and followed every step... but it didn't work. I try, try again.
  6. MatthewSchenker: I like DynaTable.
  7. Hey thanks guys. I've realized the ease of simply exporting a site profile, which is serving me well. Someone else pointed Migrator out to me too, but with the profile export I haven't even gotten around to trying that yet... I do have it installed...
  8. I have a page /team/ with url segments [1] enabled, that must equal the name of a user with a 'broker' role. On /team/ a list of all users with the 'broker' role is rendered. It does not appear if I am not logged in though. How can I enable this info to appear universally? I mean for public visitors to be able to view it as well... Then this http://processwire.com/blog/posts/processwire-core-updates-2.5.14/ has got me curious about user hierarchy, as my site will require entirely different types of users that might as well have different input fields per type, hence different templates... Are they still accessible via the $user variable if an alternative template is used? or a different parent? Thanks.
  9. That link has much interesting info... Not just the multiple-modules, but alternate user templates (wasn't really sure on the status of that being supported) and different user parents, even.
  10. I had too little faith starting over again...
  11. Thanks for the reply, Jan. Sorry about the vagueness. Understandable that that error would come up due to invalid input, but now it's not saying for which field? It did just say that the field 'roles' is not present, which I know... so I removed that specification from the visibility, but then I can't restrict visibility based on user role(s)? Then I remove the field and again it only says, "Session: Profile not saved".
  12. Thanks for trying it out. I'm using 2.5. Debug was set to false... =\ But so I went back to the screwy installation and set its config->default to true, saved my profile successfully, though sans the supposed trouble field. Then I set config->debug back to false and could still save my profile... strange... Then, once I added the office_location field back to the user template, I got "Profile not saved" again. I set debug to true and it says: above the regular "Profile not saved" red message. So I removed the visibility selector, 'roles!=37'. Now when I try to save my profile, it just says: ... You did add the field to be editable via the edit-profile screen right? Not just editing the user page? Like you add the field to the template, then make it editable in the profile via ProcessProfile config, then go to /processwire/profile/ (or whatever you have as your admin path if not processwire) and you are able to save it?
  13. I know that say I have a repeater field engines, I can do foreach($page->engines) or $page->engine_field... but is there any way to do like foreach($page->engines as $e) { foreach($e->field as $field) { echo $field->val; } } That itself doesn't work. But is there some way of iterating through a repeater field's subfields? I'm trying to add repeater field support to Import Pages CSV module... If not I may just have to figure out how to write a separate module specifically for imports of a particular page template... if I can... I can try... Anybody know about this?
  14. Bump... Must I create corresponding userinfo pages per user? Has anyone else successfully added page fields to the user template? What am I doing wrong?
  15. I read a post somewhere before when I was trying to find out about this, where the guy was creating corresponding like frontend profile pages, separate from the users themselves, to store additional profile data. I know this is totally a possibility, or a number of other ways, I guess. PW, endless possibilities. But I thought I would just do it directly. I suppose I might as well take that same route though, for the same reason: not to corrupt the native user template/variable... I mean it is slightly more time consuming, but in the long run if this is going to happen it'll actually save me a ton of time. I am curious about the answer to this question but... I could just try another way. I guess I'll go look for that thread again and see what's good, how he does it...
  16. Hey thanks for the welcome. I have definitely read through much of the documentation, forums, Google searched extensively, and tried and inspected (not that extensively but somewhat) several of the site profiles already, and yes I understand the PW structural fundamentals. I have a lot going on in this site already. I put off adding this field because that's when it happened last time, and I had to put it all back together, and then some, and now I added this field again and again I have this issue and nowhere in the documentation that I have seen does it say anything about this not being ok to do. So... this is just a freak incident it seems (except for that this is the second time, so.. 2x freaky, but I still have no answers), and I am hoping that since there doesn't seem to be anything in the documentation about this error, or anywhere in the forums, and no additional information other than the profile not saving is provided, that maybe somebody in these great forums might be able to help. Hence, this, and my last post about this. I looked at ProcessProfile.module and don't see any reason the profile wouldn't be saving. It's just an unexplained error. Like, I simply did this, nothing should be wrong with it, if something is, and I'm not doing this right, please do tell: I have /about/locations/ with children location pages. These are public, with frontend templates... if it matters... So I then I add a page field to the user template, office_location, with template=location for selector. The thing is, it works. I was able to set locations for all my users with roles=broker. However... that I did by editing the users from my superuser account, and then next thing I know, I check if I can save my profile, and I can't, and neither can I logged in as anyone else. So if page fields can be used in user templates, and this is in fact a commonly done thing, why is this happening to me, what about that is wrong that I did? Why does this break the profiles? Seems crazy to me, but there must be something I'm missing here, I just wish I knew what.
  17. I just ended up installing my exported site profile this time around and luckily it worked perfectly anyway. That wasn't too long ago, I'm ok to continue from here.
  18. You mean this? https://github.com/adrianbj/ProcessMigrator Looks quite promising. Do you know if it's compatible with 2.5? I guess I'll give it a try. Couldn't hurt at this point. I hope my install isn't already screwed even if it's exported... oy... I'll see... and report back. Thanks.
  19. I have one I want to install. I copied the index.php and /wire directory to a fresh site directory and added in its /site put all the files from my exported site profile. When I access the site it says "404 page not found (no site configuration or install.php available)". How am I supposed to install this?
  20. I would think relating users to other pages would be a fairly common requirement too, so... if it is that... 1. why won't it work when I remove the field, and 2. why would it even break my user profile saving capability in the first place? How can fix this? I don't want to start over again.
  21. I posted about this before and nobody had any input. I started again from scratch on account of this mysterious problem, and I cannot figure out how to even troubleshoot it. I really don't want to have to start it ALL over again; that'd make 3 different copies going of the same project. No particular errors are given, just that it won't save. It does seem like both times this happened after adding a page field to the user template, relating the user to an office location. If I remove the field, I am still unable to save profiles. When this first happened I removed all the custom fields from the user template and disabled every module one by one. Never again could I save profiles.
  22. I'm trying to send an email notification for each inquiry submitted. Currently they're just saved as pages. I want to email notify too. So I have (mail part is at the bottom): // check if the form was submitted if($input->post->submit) { // determine if any fields were ommitted or didn't validate foreach($required_fields as $key => $value) { if( trim($value) == '' ) { $error_message = "<p class='error'>Please check that you have completed all the required fields.</p>"; $error = true; } } // if no errors, create a new page if(!$error) { $p = new Page(); // create new page object $p->template = 'vessel_inquiry'; // set template $p->parent = wire('pages')->get('/sales/inquiries/'); // set the parent $p->name = $input->post->vessel_id . '_' . date('YmdHisu') . '_' . $input->post->user_id; $p->title = $input->post->title; // set page title (not neccessary but recommended) $p->save(); //create the page // populate fields $p->message = $input->post->message; if($user->isLoggedin()) { $p->user = $input->post->user_id; } else { $p->fullname = $input->post->fullname; $p->email = $input->post->email; } $p->vessel_id = $input->post->vessel_id; $p->status = $p->status | Page::statusLocked; $p->save(); //save the populated fields $success = true; $mail = new WireMail(); // chained method call usage $mail->to('my@email.com')->from('some@email.com')->subject('Message Subject')->body('Message Body')->send(); } This is just to test email sending period. (The to and from emails are actually different ones that I have access to.) I've tried several times to submit inquiries and am not getting anything in spam or anywhere. I'm using XAMPP on OS X. I know email is complicated and not exactly a ProcessWire matter but do you guys know how I might be able to troubleshoot or resolve this? Surely others here have experience using wireMail() on similar setups... Thanks much.
  23. $page->set($fieldName->address, $value); does not seem to work.
×
×
  • Create New...