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 recently discovered this tool http://www.kimonolabs.com/ that let you turn a website into an API. So far so good. I'm trying to imagine how to deal with json in PW. I'd like to output the data on a single page. What's the best way of doing this?
  2. I have an image 500x300 I need to apply the resizing to 150x150 without cutting edge. Thus in any case, I need to have the image canvas size 150x150 When you use $ image->size (150, 150), we obtain the desired result (cropping). When using $ image->size (150, 150, array ('cropping' => false)) our image circumcised according to the greatest height, canvas change proportionally. / / 150x90. Need an image 150x90 position in the center of the canvas 150x150. You can do this using the API?
  3. Hi, I've recently moved from Modx Revolution to Processwire and so far my experience with the platform has been great! The jqueryUI admin is much faster as compared to Modx's extJS manager. kongondo's article for those transitioning from Modx has been very helpful. Link - http://processwire.com/talk/topic/3691-tutorial-a-quick-guide-to-processwire-for-those-transitioning-from-modx/ One of the things that really bugged me about Modx was the slowness of getResources. Even after optimising and caching the getResources call, it would still produce slow response times if the number of resources were high. Now, I understand that the equivalent of getResources in Processwire is $pages->find("selector"). My question is: Has anyone had any experience with running $pages->find("selector") api call on over 10,000 pages? What are the response times like? Thanks
  4. Just gettiing started with ProcessWire with limited php expertise. So far I'm really likely it, and I'll probably switch to using it instead of WordPress. The learning curve is pretty friendly, but it would be a lot nicer if their were some examples on the api as well as the brief description. Just a thought.
  5. For example: It is necessary for you that all photos in galleries of "participants" would be in jpeg. But different types are allowed for loading, and all of them will be cut off in compliance with the type. I suggest to choose expansion in which the reduced copies of the image will be converted, it can be both control for a field, and expansion for API Image $image->ext() //jpg $newImage = $image->ext('png') $newImage->ext() //canonical png convert
  6. My organization is looking at moving our various websites to a CMS. As we have probably 20 - 30 sites, I want to do a multisite setup, using the multisite module, so that we don't need to maintain so many duplicate user accounts for our content editors. I'm wondering how I'm supposed to hook into $page->rootParent to get it to return its appropriate child. I'm thinking I'll setup the page tree so that Home is just a dummy page, and all my real sites' homepages will be its direct children. That way I think I should be able to make the change to the rootParent method universal without having issues. How could I accomplish this? Am I making some horrible mistake which I have been unable to percieve thus far? Thanks.
  7. Hey guys, I want to manage some contens for a site running on CodeIgniter using PW. But as I try to access CI, I get this error: Unable to complete this request due to an error. I tried these ones, both return that error. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); require __DIR__.'/../../cms/index.php'; class Processwire extends CI_Controller { public function index() { echo '<pre>'; var_dump($wire->pages->get('/news/')); } } /* End of file suche.php */ /* Location: ./system/application/controllers/processwire.php */ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Processwire extends CI_Controller { private $wire = null; function __construct() { require __DIR__.'/../../cms/index.php'; $this->wire = $wire; } public function index() { echo '<pre>'; var_dump($this->wire->pages->get('/news/')); } } /* End of file suche.php */ /* Location: ./system/application/controllers/processwire.php */ Any Ideas what might cause the error? PW doesn't log anything, even with debug turned on. It it CI specific, as I can use the same code using a independent php file. Thanks
  8. Hello everyone, I was just asking myself, why there are no hooks for the methods in the LanguagesFieldValue class. I was going to improve the multilanguage support with a modul that introduces fallback languages. That would mean that for each language you can declare none or many fallback languages and if there is no translation of the value in the current language, it goes through all fallback languages and looks whether there's a corresponding value defined. It would be easy to implement this by hooking to the toString() method, but it is not hookable. Do you see another simple way to implement what I need or can we get hooks in the class in core? With kind regards, Marc
  9. Hello, I have an imagefield set to limit=1 and I try to replace this image via the API: $video->of(false); $video->teaserbild->removeAll(); $video->save(); $video->teaserbild = 'http://new_image.jpg'; $video->save(); The result in the admin is a broken image (missing file) as the first image (which was supposed to be removed) and the new one intact as second. I'm on PW 2.3.0. I've had this problem for a while and can't seem to solve it. Can someone help? Thanks, thomas
  10. Hi guys, have been struggling all day with a problem creating a front-end form. The idea is that "students" are linked with "feedback" and on both templates there is a page field which links the two together. The superuser has an update feedback form on the frontend where they can make changes, set to hidden/visible as well as assigning the feedback to a student. For some reason I can get the feedback page itself to be updated, I can remove any old attachments from student pages to this feedback page but trying to update the new student to be attached is causing errors. I've had an error telling me to set OutputFormatting to false (it already is) and now I seem to be getting server errors that it's running out of time. I've included the current commented code below, can anyone see anything I'm missing? Thanks <?php // If form is submitted if ($input->post->submit_update_testimonial) { // Assign empty variables $out = ""; $error = 0; // Check if required fields empty if (empty($input->post->title) || empty($input->post->testimonial)) { $error = 1; $out = "<h3>Please include a title and testimonial</h3>"; } if ($error == 0) { // Set sanitized variables $title = $sanitizer->text($input->post->title); $testimonial = $sanitizer->textarea($input->post->testimonial); $date = $sanitizer->text($input->post->date); $student = $sanitizer->text($input->post->student); // Get current student who is attached to feedback (if any) and remove the attachment $current_s = $pages->get("template=student, student_feedback=$page"); if ($current_s->id) { $current_s->of(false); $current_s->student_feedback = ""; $current_s->save(); } // See if newly-selected student exists and if so attach it to this feedback (CAUSING ERRORS) $new_s = $pages->get("template=student, id=$student"); if ($new_s->id) { $new_s->of(false); $new_s->set("student_feedback", $student); $new_s->save(); } // Update the actual feedbcak contents from the form $page->of(false); $page->title = $title; $page->body = $testimonial; $page->testimonial_date = $date; // Update whether the feedback should be visible or hidden if ($input->post->publish == "") { $page->addStatus(Page::statusHidden); } else { $page->removeStatus(Page::statusHidden); } // If set to a student then assign it on the feedback page if ($student == "unassigned") { $page->set("feedback_which_student", ""); } else { $page->feedback_which_student = $student; } $page->save(); } // end if no errors } // end if form submitted ?> <?php if(!$user->isGuest() && $user->name === $page->name OR $user->isSuperuser() OR $user->hasRole("editor")) { include("./header.inc"); ?> <div id="feedback_item_admin" class="content"> <div class="row"> <div class="large-12 columns"> <div class="content_area"> <div class="row"> <div class="large-9 columns"> <h3>Edit Testimonial</h3> </div> <!-- /.large-9 columns --> <div class="large-3 columns"> <a href="<?php echo $page->parent->url; ?>" class="tar flr">← Return to Testimonials</a> </div> <!-- /.large-3 columns --> </div> <!-- /.row --> <hr> <form action="./" method="post"> <div class="row"> <div class="large-8 columns"> <input type="text" name="title" value="<?php echo $page->title; ?>"> </div> <!-- /.large-8 columns --> <div class="large-4 columns"> <input type="date" name="date" value="<?php echo date('Y-m-d', strtotime($page->testimonial_date)); ?>"> </div> <!-- /.large-4 columns --> </div> <!-- /.row --> <textarea name="testimonial" cols="30" rows="10"><?php echo strip_tags($page->body); ?></textarea> <div class="row"> <div class="large-6 columns"> <label for="publish">Publish?</label> <input type="checkbox" name="publish"<?php if (!$page->is(Page::statusHidden)) { echo " checked"; } ?>> </div> <!-- /.large-6 columns --> <div class="large-6 columns"> <label for="student">Relates to student?</label> <select name="student"> <?php if ($page->feedback_which_student->id != "") { ?> <option value="<?php echo $page->feedback_which_student->id; ?>"><?php echo $page->feedback_which_student->title; ?></option> <?php } ?> <?php foreach ($pages->find("template=student")->remove($page->feedback_which_student) as $student) { ?> <option value="<?php echo $student->id; ?>"><?php echo $student->title; ?></option> <?php } ?> <option value="unassigned"<?php if ($page->feedback_which_student->id == "") { echo " selected"; } ?>>Unassigned</option> </select> </div> <!-- /.large-6 columns --> </div> <!-- /.row --> <input class="button secondary small drop_down" type="submit" name="submit_update_testimonial" value="Update"> </form> </div> </div> </div> <?php include("./footer.inc"); ?> <?php } else { throw new Wire404Exception(); }
  11. Hi, I've been struggling with building forms with the API this week-end. How would i translate the form errors messages (Missing require value...) ? Thank you.
  12. Hi all, Hope for a helpful hint and thank you in advance. I am trying to create a form in the frontend with custom markup for the form and the fields. Its all fine, except that I cant find out 1. how to remove the empty "<option></option>" choice and 2. I was wandering if there is a smarter way of making one of the options "selected" in page field using select inputfield. Here is my code: $newPage = new Page(); $newPage->template = 'my_weather'; $field = $fields->get('temp_units'); $inputfield = $field->getInputfield($newPage); $select = $inputfield->getInputfield(); $options = $select->getOptions(); foreach ($options as $key => $val){ $select->removeOption($key); } foreach ($options as $key => $val){ $attr = ($val == 'kg') ? array('selected' => 'selected') : null; $select->addOption($key, $val, $attr); } echo $select->render(); Of course, I could skip render() and output my markup with the options above instead, but it is a quite large form and I prefer to know if this is the right way of getting things done with the API. Thanks!
  13. Was just wondering if anyone had any experience adding repeater items to a new page from a front-end form? The repeater consists of two fields, one a page field and the other a simple text value. I'm unsure how I'd go about adding those values on a new page save()? Thanks, as always.
  14. Hi guys, Am having an issue with a front-end form where page-fields via a select field are not getting updated. Could someone check that my syntax is correct? I'm not really sure why they're not matching up. The form part: <label for="edit_terms">Terms</label> <select name="edit_terms"> <?php foreach ($pages->find("template=payment_term") as $term) { ?> <option value="<?php echo $term->id; ?>"<?php if ($term->id == $page->invoice_terms->id) {echo " selected";} ?>><?php echo $term->title; ?></option> <?php } ?> </select> <label for="edit_status">Status</label> <select name="edit_status"> <?php foreach ($pages->find("template=invoice_status") as $status) { ?> <option value="<?php echo $status->id; ?>"><?php echo $status->title; ?></option> <?php } ?> </select> The editing page via API part: <?php $error = 0; $out = ""; // Form was submitted if ($input->post->estimate_edit_submit) { $page_name = $sanitizer->pageName($input->post->number); $p = $pages->find("template=estimate, name=$page_name")->remove($page); if (count($p)) { $error = 1; $out = "Sorry, that page name is already taken..."; } if ($error == 0) { $page->of(false); // $page->parent = $pages->get("/estimates"); // $page->template = "estimate"; $page->title = $sanitizer->name($input->post->number); $page->name = $sanitizer->pageName($input->post->number); $page->invoice_number = $sanitizer->name($input->post->number); $page->invoice_date = $sanitizer->text($input->post->date); $page->invoice_client = $sanitizer->text($input->post->client); $page->invoice_terms = $sanitizer->text($input->post->edit_terms); $page->invoice_status = $sanitizer->text($input->post->edit_status); $page->invoice_line->removeAll(); $total = 0; for ( $i=0;$i<count($input->post->invoice_billable);$i++) { ${'rp'.$i} = $page->invoice_line->getNew(); ${'rp'.$i}->invoice_billable_line = $input->post->invoice_billable[$i]; ${'rp'.$i}->invoice_billable_amount = $input->post->line_value[$i]; $total += $input->post->line_value[$i]; } $page->invoice_total = $total; $page->save(); $out = "Estimate saved successfully"; } } All the text fields are getting updated but all three select fields (client, terms and status) aren't updating. I have an almost identical template for create instead of edit and everything works fine. Been scratching my head now for a good few hours, can anyone see anything wrong with the way I'm using the API? Thanks.
  15. Hi all, Before you ask, this is part of my learning process so am not busy breaking somebody's site OK, I am now comfortable enough using foreach loops in PW. I am now onto "while loops". How can I replicate the following "while loop" code in PW? I've learnt that it is common to use similar code to access tables in a database. While there are still results, keep on getting them and add them to an array... $rows = array(); $results = $db->query("SELECT id, name, data FROM some_table"); while($row = $results->fetch_array()) { $rows[] = $row; } Now, in my case, my data is in PW as normal PW pages. I do not need to do the $db->query thing. I can use PW selectors. The $results bit is straightforward, .e.g using $pages->find('something'); I also know $pages->find(); will return an array (PageArray). Where am getting stumped is how to use the while loop to do the same thing the above code is doing but using PW API. Specifically, what I don't get is how to replicate the $results->fetch_array() bit using PW API. I have Googled the forum and haven't found anything but examples of querying external tables as shown above. I have also checked the API documentation but nothing has worked for me yet. I am either getting endless loops (white screen) or no items get added to the array . Here's my question in code. I know the $results->fetch_array() will not work here $rows = array(); $results = $pages->find('template=basic-home, limit=20'); while($row = $results->fetch_array())//how to replicate this fetch_array bit? { $rows[] = $row; } Or, should I not use the while loop in such a case? Use something else? Thanks!
  16. Hi, is there a solution to get all pages from my folder "features" where "field1" is smaller than "field2"? Is this possible with the find API? I tried it, with echo $pages->get("/features")->find("field1<field2"); but it did not work. Any suggestions how i can achieve this? Thanks in advance. Jens
  17. Hi there, I'm currently writing a module that needs a Process action to generate some previewable HTML+CSS Code. In my code I'm doing something that boild itself down to this, to generate the preview: public function executePreview() { $p = new Page(); $p->template = $this->get('template'); // configurable module variable return $p->render(); } Would be fine if this wouldn't render inside the default admin template (that I need for other actions of the same controller). This inserts a lot of CSS and JS that I can't use here. The Preview action will be embedded into another action as an iFrame and I already tried calling it with ?modal=1 which get's rid of header, footer and sidebar, but still loads the CSS and JS. What I'd like to do know is to programmatically change the template of this view, but I wasn't quite successful. I inserted this in the above code to make it render another inside my module folder, but it still renders inside the default admin template: $this->page->template->set('filename', $this->config->paths->MyModule . 'my-blank-template.php'); While this would be pretty hackish, it also doesn't work... but I really hope that someone of you has a better answer to this problem? With kind regards, Marc Edit: While stepping through the code I wondered, where exactly the $page->render() function is?
  18. Hello, I run a lot of websites that scrape data and insert it into the database, then use the data to display on the pages. Besides using the admin area, is there a built in way to insert new data into the cms somehow? Thank you, Chris
  19. Hello everyone, looking at the API docs I just noticed, that in the class Page there is a method isHidden() but no method isPublished(). As I understand it, the proper way to to get the published status would be: $isPublished = !($page->is(Page::statusUnpublished)); Since I'm ok with that, I think it is a little incoherent to have a convenience method for the first but not for the latter. Or did I miss something here? P.S.: What I want to do is to show some infos in the frontend to the content editors like whether the page is hidden or published. Just looked strange in my code so far.
  20. Hello everyone, I'm currently working on a simple module (view this thread for more details) and ran into some problems with the validation of input data. I did some research, but I wasn't able to find answers to these questions: 1. If you develop your own Inputfield/Fieldtype module, where do you do validation? I've seen other modules do it in Fieldtype::sanitizeValue() (apigen), but this seems rather strange to me. Also, as far as I got it, they didn't throw any errors back to the user but just quietly changed everything, that doesn't make sense without the user knowing it. This leads to the next questions: 2. What is the correct way to get visual validation error reports to the user? 3. How to prevent a page from saving with validation errors? With this fairly basic stuff (where I wasn't really able to find something meaningful about) out of the way, what I really want to know is this: 4. How do you add validation with error reporting to an existing Fieldtype module? I want to add my custom validation with error reporting to the standard FieldtypeTextarea module (only when some conditions are meet in the corresponding Inputfield for sure), but I have no clue what would be the way to go there and wasn't able to find any module that does it like this. Please shed some light on these question, would be very much appreciated! Marc
  21. Hello, when I delete a page with repeater fields, the fields data stays in the DB. Is there a way to delete these or a way to find out which data in the "pages" table is from repeaters? I added and deleted about 4000 pages via a script and now my "pages" table is a mess ... Thanks, thomas
  22. Hi, I'd like to have an "edit" option for pages in the frontend. I thought I could append an urlSegment to the page url and (instead of coding show and edit functions into one template) simply switch templates: if($input->urlSegments[1] == 'edit') $page->template=$templates->get('page_edit'); This code doesn't work ... Is this even possible or do I need to redirect or put all code in one template? Thanks! thomas
  23. Hi again guys, as part of my plan to offer a fully-fledged front-end student management system for my site, I'm trying to add a page where there is a list of all students and a checkbox next to each name. Whichever student has a checkbox next to their name gets deleted upon form submit. Have tried the following but think I have lost my way! <?php if($input->post->submit) { $students = $pages->get("template=students")->children(); foreach ($input->post->$student->name as $s) { if (isset($s)) { $deletable = $users->get($student->name); $deletable->delete(); echo $deletable->name . " has been deleted!"; } } } ?> <form action="" method="post"> <ul> <?php foreach ($students as $student) { ?> <li> <?php echo $student->name; ?> <input type="checkbox" name="<?php echo $student->name; ?>"> </li> <?php } ?> <input type="submit" value="Delete selected users" name="submit"> </ul> </form> Am I missing something simple here? For those who are stuck doing similar things, I have managed to get the adding and modifying students front-end bit pretty sorted I think so more than happy to lend a hand!
  24. Sorry, but can find no reference to be able to create pages using the API but am sure it's possible. Is there a reference anywhere? At present, I'm using guesswork.. $new_page = new Page(); How do you set the name, template and parent? Any nod in the right direction would be much appreciated.
  25. Hi there, I am trying to get a group of pages from Processwire, but I want to group all of the similar pages and show a count next to them. Is there something I can do in Processwire to achieve this? I know I can get all of the pages and sort them like this and I can add ->count() to count them, but I want to achieve something like the SQL command GROUP_BY $pages->find("template=template, sort=sort") Thank you for any help here...
×
×
  • Create New...