Jump to content

Search the Community

Showing results for tags 'API'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

  1. Hello, i have a landingpage and need to reaname the images or save it to the filed images in the userpage i have this script currently if(isset($input->post->submit)) { $lptitle = $sanitizer->text($input->post->lptitle); $anrede = $sanitizer->text($input->post->anrede); $first_name = $sanitizer->text($input->post->first_name); $last_name = $sanitizer->text($input->post->last_name); $str = $sanitizer->text($input->post->str); $num = $sanitizer->text($input->post->num); $plz = $sanitizer->text($input->post->plz); $ort = $sanitizer->text($input->post->ort); $land = $sanitizer->text($input->post->land); $email = $sanitizer->text($input->post->email1); $fbname = $sanitizer->text($input->post->fbname); if ($page->id == '2328' ) { // Set a temporary upload location where the submitted files are stored during form processing $upload_path = $config->paths->assets . "files/stickers/"; // New wire upload $file = new WireUpload('file'); // References the name of the field in the HTML form that uploads the photo $file->setMaxFiles(1); $file->setOverwrite(false); $file->setDestinationPath($upload_path); $file->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $file->execute(); // echo "Passt"; } // $group = $sanitizer->text($input->post->group2); if ($sanitizer->text($input->post->group2) == "on") { $group = "1"; }else{ $group = "0"; } $mail = \ProcessWire\wiremail(); $mail->to($email)->from("mymailhere@domain.com"); $mail->subject("Deine Anmeldung zur $page->title !"); $mail->bodyHTML("Hey $first_name,<br> <br> deine Anmeldung zur <b style='color: #4fc3f7;'>$page->titleaktion</b> war erfolgreich.<br> $page->mailoben Deine Angaben:<br> $anrede $first_name $last_name<br> $str $num<br> $land - $plz $ort<br> $email<br> $fbname<br> <br> Wir wünschen dir auf jeden Fall schonmal viel Erfolg und erfrischende Grüße!<br> $page->mailunten Gerne kannst du auch deinen Freunden von unserer $page->titleaktion per Facebook, Twitter, Google+, WhatsApp oder E-Mail berichten:<br>"); $mail->send(); $p = new Page(); // create new page object $p->template = 'fans'; // set template $p->parent = $page->id; $p->title = $first_name." ".$last_name."-".$page->numChildren; $p->gender = $anrede; $p->first_name = $first_name; $p->last_name = $last_name; $p->str = $str; $p->num = $num; $p->plz = $plz; $p->ort = $ort; $p->land = $land; $p->email = $email; $p->fbname = $fbname; $p->letter = $group; $p->save(); $p->images = $upload_path . $files[0]; $p->save(); @unlink($upload_path . $files[0]); } How to save the Image to the Userpage ? Thanks
  2. I'm building an upload form for user to add images to a page. I would like for the user to change the image order after they add the images. Basically how the image field in the backend works. So users can drag and drop the image order. The problem is that I don't know how to rearrange the data of my image field based on the order a user submits?
  3. Hi all, I am working on a module which creates templates, fields & pages upon install. I have ran into an issue where I have a numerous fields which I would like to override their labels depending on the template they are used in. Is it possible to do this dynamically via API at the point where I am creating the field group and template using the API. The following is the code which I am using at the moment. foreach($templatesArray as $name => $cTemplate) { if(array_key_exists('fieldGroup',$cTemplate)) { $fg = new Fieldgroup(); $fg->name = $name . '-fg'; foreach ($cTemplate['fieldGroup'] as $field) { //possibly at this point? $fg->add($this->fields->get($field)); } $fg->save(); } $t = new Template(); $t->name = $name; $t->fieldgroup = $fg; $t->noChildren = 1; $t->setIcon($cTemplate['icon']); $t->save(); } Is this even possible?
  4. Hi All, I am working on a module at the moment which in theory will create a few simple fields, templates and pages which will all be linked together. All is going well so far, I have it generating said fields, templates and pages, however I would like to also set the pages sort order and icon programmatically at this stage also. I have yet to see any documentation or any other threads where this has been brought up, is it even possible programmatically without interacting with the database directly? This is the snippet which is generating my pages on the fly at the moment. foreach($arrayOfPages as $name => $page) { $p = new Page(); $p->template = 'page'; $p->name = $page['URL']; $p->title = $name; $p->parent = wire('pages')->get('name='.$page['parent']); //is it possible to set the icon and sort order at this point, before saving? $p->save(); }
  5. I have a hook that creates a page for a subset of the pages on our site. It uses the saved page's name as part of the created page's name. The problem I am having is that my hook, attached to Pages::saved(), is being called even when the page save failed because of missing fields. Is there a way I can tell that the page save failed due to missing fields? Never mind - it does succeed; it just issues warnings about required fields.
  6. Hi, I'm sure this is maybe in the works already, given that findMany() is a recent addition to the API, but having this (and the other new find options) available to $users would be a great addition. Cheers, Chris NB Communication
  7. Hi folks, On the website I am working on I do have a form which needs to be filled in (duh) and when the user clicks on download, the data is send with ajax and processed in the same file by using the ProcessWire API with $config->ajax; The data which is provided by the user will be checked with data in my database. If the data is correct I want to push a file download. But this is not working at the moment. It seems like the content of the (.exe) file is pasted in the console instead of pushing the file. My code looks like this: if ($config->ajax){ $serial = $input->post('serial'); $DB = DB(); $query = $DB->prepare("/*My query here*/"); $query->bindParam("comparision", $serial, PDO::PARAM_STR); $query->execute(); $reply = ''; $SN_rows = $query->rowCount(); if (!$SN_rows > 0) { $reply = 'error'; } else { $reply = 'success'; $installer = $page->attachments->eq(1); $filename = "Filename"; $filepath = $installer->filename; $options = array( 'forceDownload' => true, 'exit' => true, 'downloadFilename' => $filename ); wireSendFile($filepath, $options); } echo $reply; exit(); } What am I doing wrong here or is it a bug? Is there another way to do this with the processwire API? Thanks in advance, ~Harmen
  8. Hi everyone, I've recently hired at a new company and here I am evaluating the abilities of ProcessWire for our projects. I was able to meet almost every requirement so far, but there is one point I couldn't find an adequate solution for: outputting data to json. I am aware of modules like https://modules.processwire.com/modules/pages2-json/ (which does not seem to work for me) but I thought with a function like wireEncodeJSON this should be much cleaner. What I would like to achieve is outputting pages with according field values into an array to use this within javascript. My first attempt on this was: $jsontestOne = $pages->find(1001)->children(); echo wireEncodeJSON($jsontestOne); which outputs [{}] and afterwards I tried that one: $jsontest = $pages->find("template=basic-page")->getArray(); echo wireEncodeJSON($jsontest); which outputs [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},...] Maybe you can point out where my mistake is. Thanks in advance!
  9. Hello! I'm trying to use the data I create in Processwire as much as possible. So for a form, I try to use the fields description, name and also its built-in validation rules I defined in ProcessWire on the front-end. (minlength, ranges, patterns, etc) I already looked into this tutorial, but it is using external resources to validate the form. Since ProcessWire does all the heavy lifting, when processing data, I don't have to sanitize anything - ___processInput should do the job just fine. However, it is not actually working correctly. $fields = $templates->get('user')->fields; $submission = $input->post; foreach ($submission as $key => $value) { $field = $fields->{$key}; if ($field instanceof Field) { $field = $field->getInputfield($user); $field->___processInput(new WireInputData([$key => $value])); var_dump($field->getErrors(true)); // retrieve validation error } } This works for some constraints, but the values are not correctly validated. Example: All the fields are required and zip is an integer field. Yet, I get no validation error for zip, although it was entered as a string, and not an integer. Funny enough: if I provide a number outside the range, I get "Specified value 2 removed because it is out of bounds (min=1000, max=99999)". firstname will not return any error for being a required field. From what I have looked through the source code, there is no check for "required". Some fields only validate on setAttribute. Am I missing anything or am I doomed to build my own validation process? Thank you in advance! Best, Martin
  10. Do any experts have experience with the level of stability and/or support for turning on $config->advanced? I ask because of the warning at the bottom of the System tab "Please note that all of these system settings are intended for ProcessWire system development (not site development). Use them at your own risk." It provides two facilities that are invaluable to me (maybe because I don't know how to do them any other way). 1) Disable Settings Tab on a per template basis 2) Page Class Name - this makes it tweak a page while relying on the underlying Page class for the majority of functions. Are others using this setting in production? Have you used it over an extended time and seen that it is not changed often or at all?
  11. I have a Page Table field that, for new entries, I want to construct the name for. When I click the Add New button the page being added has already been given a random name like: 20170422-003744. I wish to 1) change that name so it's obvious it is a temporary name and 2) when either Publish or Save + Keep Unpublished is clicked, set the name of the page based on the content entered. What hooks can I use to accomplish 1 and 2? thanks.
  12. Good afternoon, I am attempting to loop through approximately 600 XML nodes. Each of those nodes has 2 child nodes (example below). One is an id for an existing page and the other contains values for a page reference field. I have put together a loop (below as well) to attempt to save each page with the label values. This all works....once. After getting the first XML node "label" saved to the correct page, nothing else is saved. I'm sure there is probably something that I have overlooked. But, I am also very new to this CMS. I'm hoping there is a veteran user who may be able to point me in the right direction. <row> <id>1041</id> <labels>lifestyle|savings</labels> </row> foreach ($xml->row as $items) { //get page id to update and set output formatting to false $blog_page = $pages->get('id='.$items->id); $blog_page->of(false); //create array from pipe separated label values $labelsArray = explode('|', $items->labels); //loop through array to get page ids by page name $labelIDS = array(); foreach ($labelsArray as $labelValue) { $labelPage = $pages->get('name='.$labelValue); array_push($labelIDS, $labelPage->id); } //add labels to label field in post $blog_page->labels = $labelIDS; //save page $blog_page->save(); }
  13. We have a three language web site - 'de', 'en', 'fr' with 'de' being the default. There are pages for which we want to use the name (it's unique within its parent-scope) as in the attachment. But when I fetch the name it does not return the name for the language - it always returns the name for the default language (guertel, in this case). I've tried $page->getLanguageValue($lang, 'name'), but name is not a "real" field, so it returns null. I can hack around it by extracting the last segment of the URL associated with that page (which is language sensitive) but it seems like I must be missing something. Is there some way to fetch $page->name for the $user->language setting?
  14. Hi all, I'm just trying to update a custom field value for a page but I noticed in the DB that the old value is still there? Rather than updating, it appears to create a new record for the updated value and increments the sort value. Why is this? Is it not possible to just overwrite the value within the DB using the API? For example: $pageObject->of(false); $pageObject->customField = "Updated Value"; $pageObject->save(); $pageObject->of(true); I would have expected the value just to be overwritten and persisted to the field table in the database? Obviously I am missing something or just not grasping why it works like this?
  15. This is probably really simple but I am unable to get the two letter code for the default language. $languages->default gives me a numeric code (the page ID for that language). $user->language give me the numeric code again $user->languages->name gives me "default" if it is the default language, else the two-letter code for the language. But I don't see the two letter code for the language in $config (I might be missing it) nor anywhere else. I've hardcoded around this now, so the question is largely academic, but I'd prefer not to hardcode it. Being able to get the two character code, and not 'default' for the default language would be equally helpful.
  16. This morning I pushed a module to github which extends the page api with moving and sorting capability. https://github.com/kixe/PageMove * CALLABLE (static & instance) * PageMove::execute($page, $parent = null, $newIndex = 0, $selector = 'all'); * $modules->get('PageMove')->execute($page, $parent = null, $newIndex = 0, $selector = 'all'); * * EXTENDED PAGE API * @method $page->move($parent, $newIndex = null, $selector = 'all') * @method $page->setIndex($newIndex, $selector = 'all') // set absolute index include=all * @method $page->getIndex($selector = '') // same as $page->index without argument @see getSelector() * * @method $page->moveFirst($parent = null) * @method $page->moveLast($parent = null) * @method $page->moveForward($steps = 1, $selector = 'all') * @method $page->moveBackwards($steps = 1, $selector = 'all') * * @property $page->moveFirst // same parent * @property $page->moveLast * @property $page->moveForward * @property $page->moveBackwards * * EXTENDED PAGES API * @method $pages->move($page, $parent = null, $newIndex = 0, $selector = 'all') * @method $pages->resortChildren($page, $selectorValue) * // same like core function $pages->sort($page, true); with capibility to change the sort condition Have a nice weekend.
  17. I am fairly new to Processwire and using APIs and I wanted to implement a certain functionality for one of my templates. Suppose I want all pages that use template A to display wiki content associated with page->title in page->body . For example if page->title is "Google", I want the body to consist of the data present on https://en.wikipedia.org/wiki/Google I understand that one way of doing this is using APIs from Wikipedia (but I do not have good experience in working with APIs) Could someone guide me though the process or point me to an already available module for this functionality in Processwire?
  18. Hi all, I do have a form in the 'backend' of my website which has a fieldtype of ASMSelect. I gave all the options of that field a custom attribute with a value: foreach ($feature_group['features'] as $feature_id => $feature) { $field->addOption($feature_id, $feature['name'], array('data-feature_group' => $feature_group_id)); } How can I read out the value of that custom attribute named data-feature group? I've tried it with $selected_feature_groups = $form->get($category_id)->getAttribute('data-feature_group'); //AND selected_feature_groups = $form->get($category_id)->feature_group; but that doesn't work. How can I get this to work? ~Harmen
  19. I have an already created web app of many php and other files. I want to access the PW API, especially for user info. Do they need to be inside the PW folder to do so? thx.
  20. I am thinking about using processwire for a special task - I have a shopping site with many product categories stored in a category tree. For each category id I want to provide content elements (texts, pictures, etc.) So I would like to import the category tree into processwire and define a template there to hold the content elements. My shopping site then would (via api?) send the category id to processwire and retrieve the content elements for this category id - so far my idea. Is this possible and easy to realize with processwire? Thanks!
  21. i have a page with similar repeater fields of various names, and similar output in a loop so i really don't really want to write endless foreach repeater for rendering but need to aggregate all repeater fields and then pass them via one foreach loop $repeaters=$pages->get("/advert_page/"); foreach($repeaters->fields as $repeator){ if($repeator=="title")continue; echo $repeator->summary; echo $repeator->images->first; } it simply doesnt work, so i have to manually do for each repeater $repeater=$pages->get("/advert_page/"); foreach($repeater->Media as $m) { echo "<img src='{$m->images->first()->size(120, 60)->url}'>"; echo "<p>Year built: {$m->summary} </p>"; } echo '</div><div class="uk-grid uk-grid-width-medium-1-4" data-uk-grid-margin="">"'; foreach($repeater->featured as $m) { echo "<img src='{$m->images->first()->size(120, 60)->url}'>"; echo "<p>Year built: {$m->summary} </p>";
  22. I'm just curious why $page->httpUrl returns mysite.dev/about-us/ When it should return mysite.dev/about-us when the template's settting "Should page URLs end with a slash?" is set to "No" I also noticed $page->url returns correctly mysite.dev/about-us Is that a bug with $page->httpUrl in the Processwire API or am I missing something?
  23. HI! I'm finding myself more and more balancing making get and post requests to templates or to admin modules, when really it would be nice to send all requests to a API url and get data back or a receipt. My example would be to click a link in an email to then make a setting change in PW, like change a specific user role, or publish a page draft etc. Has anyone done much of this and how did you structure it? I was thinking of maybe creating a template for my API and then using the $input inputs and whether you are logged in or not as starting points for sending data back for my API requests specific to my website (a news site with hundreds of members).
  24. clsource

    Voxgram

    Hello I opensourced my Telegram bot called "Voxgram" https://github.com/NinjasCL/voxgram Now you all have an example of working with the Rest Helper and the Python Telegram Framework (I think the my python code is a mess) but anyway here you go :).
  25. Hi Guys I have an helper module where I am doing different Hooks and other additional logic for a website I am developing. I looked into the code of the module and noticed something. I am using API Variables in different ways. For example: // Creating FilenameArrays wire("config")->siteScripts = new FilenameArray(); // Creating logs wire("log")->save("selector", $event->return); // Getting languages $this->wire("languages") // Setting Debug mode (Depending on roles/usernames $this->config->debug = true; etc... Now my question is, does it matter if I am using... wire("apivar") $this->wire("apivar") $this->apivar And does it matter if I am mixing these method of accessing the api variables? PS: Module is extending WireData
×
×
  • Create New...