Jump to content

elabx

Members
  • Posts

    1,479
  • Joined

  • Last visited

  • Days Won

    21

Everything posted by elabx

  1. What if you set the hook to happen before?
  2. Hook it in your in the inputfield's render's method: $this->addHookAfter('InputfieldText::render', $this, 'addButton'); In the addButton method, check for the field's name, so it doesn't render everywhere.
  3. For this to happen you must be using somewhere the $user variable which is the one that refers to the user in session. I'm thinking this is what you are looking for, so when Bob is logged in, $user will refer to Bob, and when Amy is logged in, it will refer to her user: $current = $pages->find("template=secondary, page_author=$user");
  4. FormBuilder does allow this by hooking into it. Check this blog post, it gives a hook reference for FormBuilder. http://processwire.com/blog/posts/formbuilder-v34/ Sounds to me that some hook work could help solve this too.
  5. Yes, you have to check if the page you are trying to reference exists, if not, create it through the API. For educational purposes, you can check how InputfieldPage does it. See how it iterates through the titles it receives as input, and makes decisions based on the page already existing or has to make a new one. https://github.com/processwire/processwire/blob/master/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module#L840
  6. Use this to get all the options, iterate on it and just check if the value equals the page field value: $field = $fields->get('countries'); $all_options = $field->type->getOptions($field); Check the documentation for more useful on select options fields: https://processwire.com/api/modules/select-options-fieldtype/#outputting-selected-options-on-a-page
  7. You cannot delete the pages directly from javascript, you have to make a call to the server. My recommendation from what I can tell from your module, is to turn the list of checkboxes into an actual form: $out = "<form action='.' method='post'>; Remember to close the form tag and also add a button for submit! Check the boxes, click the submit button an there goes the request to the server. You then check on your execute() method for the comment input like: public function ___execute() { if(count($_POST['comment']){ foreach($_POST['comment'] as $comment){ wire('pages')->delete($comment); } } //rest of the code One difference here from what I read on your code, the wire() function which holds all the PW variables you are used to use on templates. After you delete them, the rest of your logic can stay the same, as it will only find the pages that haven't been deleted.
  8. wireshell new --profile=blank Your new best friend! ?
  9. Quickiest/dirtiest I can think of is adding extra javascript to the admin pages and trigger the click on the tabs: http://soma.urlich.ch/posts/custom-js-in-processwire-admin/
  10. For starters it appear that you would need ImageMagick installed on your server to make the format conversion. If time is an issue, I'd use two fields paired up in repeaters, or pages themselves, so the user can upload the pairing of jpeg and the tiff file. Though I understand making the user convert/upload the image is a pain point ? You could add a method to the Pagefile class through a hook like this: https://github.com/fbg13/FieldtypeFileS3/blob/master/InputfieldFileS3.module#L21
  11. Try: $rep = $ref->repeater_field->get(1222); It should get the you the repeater item with ID 1222. This is a RepeaterPage which is pretty much a normal Page object. I don't have very clear how you know which repeater item you want to edit and where are you getting the data that is meant to be set on the repeater items. Every repeater field is an array of pages, where you can also use the find/get methods to match pages through selectors. Also, every repeater Item can have it's fields set and saved pretty much the same as normal pages.
  12. @Uniteam Anything showing on your logs? Under Setup > Logs.
  13. Sorry, my bad, understood the problem wrong from the beginning. Just tested a similar code on an installation I have. I think this line should fix it i think you where trying to get the value from $f which is just the Field object data. $rdata[$f->name] = $field->get($f->name);
  14. I think you are iterating the repeater items assuming they are like fields, so when you assign $rdata, the array is indexed by the page name (each item being a name), and $f->get($f->name) is trying to get a field, but by using a page ID, maybe that's why it's not getting anything.
  15. $p = $pages->get("/".$pageId."/"); I think with this syntax you might be trying to retrieve a path with the ID, which i don't think will work unless your page name and tree location actually matches the Page ID, try just getting it like this: $p = $pages->get($pageId);
  16. Sooo, there is another one now haha Maybe this time it takes off? Link to server
  17. Try setting template_id as an integer: $field->template_id = $templates->get("mm_state")->id
  18. Is there a smart wat to go about comparing two selectors to see if they are exactly the same? I want to iterate through a group of pages with selector fields, and compare each field selector string to another one coming in through $input->get eg. "baths>1, template=listing" == "template=listing, baths>1" //should return true. I've seen that this (Selectors:: keyValueStringToArray) static helper just handles "=" operator and discards other selectors with a different operator when converting the selectors to an array. (my objective was to compare both arrays)
  19. Also take a look at pro module Visual Page Selector which I think enables a kind of lister in the page editing.
  20. elabx

    So happy :)

    Congratulation @flydev !! You are an amazing contributor to this community and it shows in how you influence businesses decisions with your work and dedication and that's invaluable for all of us looking to get jobs using PW.
  21. @itsberni For the issue, What I've done to solve this is that I basically build a button separate from the calendar and build the url accordingly. Will get back with code details later, just in a bit of a hurry now. For the question, Doesn't passing a selector in the renderCalendar options let you filter the events you need? So that you could could use p=1 in the query parameters?
  22. Hi! I'm working on a module, and doing some Ajax operations, for example, I am creating some fields and doing this while checking if field already exists: if($fieldExists){ throw new WireException('Field already exists with that name. Please choose another name'); }else{ ... } In the response, I'm heading a 200 response code and the following code: {"error":true,"message":"Field already exists with that name. Please choose another name"} Is there a way I could customize that error message? if($fieldExists){ throw new WireException(array("message" => "...", "existingFieldId" => 1)); }else{ ... } And expect the response to have the custom info I want? I'm very intrigued on how the exception ends up as a json object in the resopnse. Thanks for further answers!
  23. Hi! Is this a valid approach to creating fieldsets? Doing this inside a module: $field = new Field(); $field->type = new FieldtypeFieldsetOpen(); $field->name = $sanitizedName; $field->label = $fieldLabel; $field->save(); $closer = $field->type->getFieldsetCloseField($field, true); Taken from here: https://github.com/processwire/processwire/blob/48fe0769a4eb3d0f5b4732fd01b4b4ed8262d952/wire/modules/Fieldtype/FieldtypeFieldsetOpen.module#L131
  24. I think the only available way built in is to use ASM inputfield with page fields and the setting becomes available in the Input Tab in the field configuration.
  25. Try to turn off output formatting before changing the value.
×
×
  • Create New...