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. Hi Forum, I recently had a chat with a friend who was introduced to PW by me. He said: "brilliant cms, poor documentation." His comment makes me think about the cheatsheet: While we see new API methods introduced at a very fast pace, the cheatsheet doesn't seem to keep up. That's sad, because it's such a good resource. So, how can I (as a user with very limited PHP skills) help to update the cheatsheet? Is somebody skilled willing to team up with me - as kind of a supervisor - for the update tasks? Or are there any plans on behalf of the team to update the cheatsheet? Thanks!
  2. I know how to create pages with the API. I need help with the form itself. Here's what I'm working with so far, hacked together from examples found in this forum: <?php $upload_path = $config->uploadTmpDir; $out = ''; // create a new form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'upload-form'); // create file field $field = $modules->get("InputfieldFile"); $field->label = "Audio File"; $field->attr('id+name','audio'); $field->description = "Upload your track(s)"; $field->destinationPath = $upload_path; $field->extensions = "mp3"; $field->maxFiles = 10; $field->maxFilesize = 2*1024*1024; // 5mb $field->required = 1; $form->append($field); // append the field // oh a submit button! $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Upload"); $submit->attr("id+name","submit"); $form->append($submit); // form was submitted so we process the form if($input->post->submit) { // user submitted the form, process it and check for errors $form->processInput($input->post); if($form->getErrors()) { // the form is processed and populated // but contains errors $out .= $form->render(); } else { // do with the form what you like, create and save it as page // or send emails. to get the values you can use // $email = $form->get("email")->value; // $name = $form->get("name")->value; // $pass = $form->get("pass")->value; // // to sanitize input // $name = $sanitizer->text($input->post->name); // $email = $sanitizer->email($form->get("email")->value); $out .= "<p>You submission was completed! Thanks for your time."; } } else { // render out form without processing $out .= $form->render(); } $content .= $out; That outputs the form but I can't drag & drop or input more than one file, and when I submit it says "Missing required value". I need to at least create one or more pages from the form submission, i.e., one per file uploaded. If possible I'd like to be able to set the title and description for each file/page as well.
  3. Hello, first thanks for this awesome project. My question is, I'm importing data from a CSV into pages whose template has a repeater, everything in the page fill's correctly(It even has images attached to it) but no repeater's are added. Something like page(song) -> repeater(videos of the song) I copied the code from http://processwire.com/api/fieldtypes/repeaters/ wich is the "Default" or basic way to populate a repeater using API. require("../../../index.php"); //Add processwire index (Bootstraping) $template = wire('templates')->get("song"); $parent = wire('pages')->get("/container-songs/"); //Array $rows_from_csv has been previously filled and is correct //The template has a repeater field called rep_videos foreach($rows_from_csv as $key=>$song) { //Start creating each page //$esiste = wire('pages')->get("template=canzone,title=$canzone[titolo]"); $p = new Page(); $p->of(false); $p->template= $template; $p->parent= $parent; $p->title=$key; $p->titolo=$song['title']; $p->testo=$song['text']; $p->description=$song['descrip']; $i++; //Load the repeater for each video the song has foreach ($song['videos'] AS $v) { if ($v<>'') { $i++; $repeater = $p->rep_videos->getNew(); $repeater->title="$key-$i"; $repeater->video_url = 'http://www.youtube.com/watch?v='.$v; $repeater->save(); $p->rep_videos->add($repeater); $p->save(); } } } Maybe the problem is that the code segment is inside a foreach? I've tryed different approaches, like saving the page before the loop that try to creates the repeater but returns an error: Error: Uncaught exception WireException with message Can't save page 0: /1444373775-0463-1/: It has no parent I've tryed saving the page after the foreach so each element of the repeater remain's in memory until finish adding new element's (Video url in this case) with no positive results. Even tryed to create the repeater of the foreach using literally the code from Repeaters Page Any help will be appreciated.
  4. Hello, I am developing a module that lets a user create, modify and save a "TV Grid" (the schedule for a TV channel). Here you can view some images that illustrate the concept: https://www.google.com/search?q=tv+grid&tbm=isch Of course, those are just examples and do not represent my specific implementation, but with that I hope you get the idea. The module installs a template for a "channel" (among other things). The "channel" has a "Repeater" field, where I store the complete grid for that channel. The repeater (grid) contains repeater items (grid items) that represent a scheduled show, e.g. ["Friends", Monday, 1st show of the day, lasts 60 minutes]. The repeater field is hidden from the user if he/she tries to edit the channel page via the admin's page edition interface. The intended way to edit this TV grid is by using the module's page that I've developed, which provides a custom interface for creating, manipulating and saving the grid. This of course means that I'm doing many things programmatically. The problem is that the repeater items I'm creating via code using the user's input just WON'T save. I've made all the code changes I could think of, trying different stuff, without positive results. Looking at the database, I notice the following when I run my code: - The corresponding row for the repeater field in its table is updated/saved. - However, no new rows are created for the repeater item fields (e.g. TV Show, duration, day, etc.). Would you please help me out here? I'm becoming insane ... I've included some code below. /* * More code before this, ommited because it isn't relevant. */ // Get the channel object (a Page). $channel = wire("pages")->get($channelId); if(!$channel->id) { $this->error("Channel does not exist. Grid can't be processed."); return ""; } // We need to clean this channel's grid before working with it. // "channel" is the Page // "tvChannelGrid" is the Repeater $channel->tvChannelGrid->removeAll(); $channel->tvChannelGrid->save(); $channel->save(); // Save the page.*/ // Add the grid items received from the module's form to the channel's grid. foreach($tvGridData as $i => $item) { // "tvGridData" is an associative array with data received from a form. $showId = intval($item["tv_show_id"]); $duration = intval($item["duration"]); $day = intval($item["col"]); $row = intval($item["row"]); $gridItem = $channel->tvChannelGrid->getNew(); // this must be done according to the documentation. $gridItem->save(); // Save the newly built item. // Assign values to repeater fields. $gridItem->tvChannelGridShow = wire("pages")->get($showId); // FieldtypePage $gridItem->tvChannelGridShowDuration = $duration; // FieldtypeInteger $gridItem->tvChannelGridShowDay = $day; // FieldtypeInteger $gridItem->tvChannelGridShowRow = $row; // FieldtypeInteger $gridItem->save(); // Save the newly built item. $channel->tvChannelGrid->add($gridItem); // Add the new item to the repeater. } $channel->tvChannelGrid->save(); // Save the repeater. $channel->save(); // Save the page.
  5. Is it possible to delete and edit pages from the frontend? Because I know its possible to create pages via the API from the Frontend. Even when the user role only has view permission and not edit permissons. creating pages: https://processwire.com/talk/topic/352-creating-pages-via-api/ https://processwire.com/talk/topic/3105-create-pages-with-file-upload-field-via-api/
  6. Hi, I have a simple question. I need to do additional logic right after a new page has been created/saved, to be more specific I need to call an API with the value of some of its fields, is this possible in process wire? Thank you!
  7. Hi folks! I'm currently using the Pages::__save() hook within a custom module to inform an external service that a page was saved. Now I only need to inform the external service if a valid page was saved (no field validation errors occurred). ProcessWire saves the page (even published pages) regardless of any field validation errors (e.g. missing input for a required field). Is their any way of validating a page instance within my module? Something like $myPage->isValid()? It would also help if someone could point me to the relevant lines of source code where the ProcessWire editor validates page input on saving. Regards, Marco
  8. Short question: Is it possible? Longer explanation: I have a rather big product cataloque which is viewable for registered users only. We now want to open it to the public. In the valued spirit of "I'd rather take 30 minutes to script something than 20 minutes to do it manually" I am looking for a way to change the access of 50 or so templates to "viewable for guest" but I can't find an API method. Can anyone help? Thanks, thomas
  9. Hi, is there any way of deleting the entire contents of an array from the API? I have had some success removing an item with: $page->image->remove($page->image->first()); But as I have to specify the item within remove() I'm not sure how to remove all the items. Thanks
  10. Hi all, I've been working on this for ages, but I cannot seem to find a generic way to exclude pages (subtree's) from the admin interface depending on a known rootParent id. My case: I have a site-tree like: HOME - Client A - Client B - Client C My subdomain determines which client we are. I have a hookAfter in a custom module that attaches to: ProcessPageList::execute This filters the tree so that when the user logs in at: clientA.domain.com the pagetree in the admin interface only shows: HOME - Client A Thus filtering by rootParent But, I'm trying to hook into for example the Pages::find to make a more generic way of filtering, so that also the Search (ajax or lister) are working correctly. They now also return pages from the other subtrees like Client B etc. Is there a workable 'generic' hook to filter results within processwire? Background on setup: My setup is done this way to have a shared /site/modules, /site/assets, /site/logs etc. but to have a client specific /site-clienta/templates My core code in this application (it's not a public site, it's actually a narrowcasting system) is centrally managed within /site/ And templates are maintained within a clients' /site-client It is all running in the same database (so that I don't have to maintain multiple instances/code/settings etc) I made some changes in /index.php so that I have a $siteCore and a different $siteDir, this way, only templates are in the clients site directory. The siteCore also has templates, which are in code included in the clients templates if needed... This setup works great and is remarkably easy to maintain (shared templates, custom templates (overrides), central modules, shared users, etc.) The only thing missing is filtering all pagetree results (everywhere, but now mainly search/ajax results) by client rootParent. I looked into using permissions/roles, but the hassle to maintain it is not worth it... I already know by the domainname what to do, so I don't want to implement a different layer... The current setup allows me to very quickly add a new client by simply create a rootParent with a pageName like: site-clientD and a directory /site-clientD and /site-clientD/templates and I'm ready to customize it where needed, letting the core handle defaults etc.
  11. Hello, i try to write an Import Script. Some basic skills i've learned from different postst. But its not really enough so i try to start a new Topic. I have an zip file with xml and images inside. The different objects have three different actions "ADD | CHANGE | DELETE" so the Idea is at the ADD Action to check is the page ID I use for the ID the Object Number alredy exist. If not create page if the Change Action than check if ID exist grab this Page and write new values if Delete Action then Grab this ID if exist and change Parent. IMPORTANT: After all I have to delete the Zip file and all the TEMP Files. How to handle in the right way temporary fils with processwire ? Maybe i dont need the external extract Script ? This is my current CODE: <?php $userRolesSelector = 'superuser'; // bootstrap ProcessWire. Update the path in the include if this script is not in the same dir include("./index.php"); if( ! wire('user')->hasRole($userRolesSelector)) { header('HTTP/1.1 403 Forbidden'); exit(1); } include "import/op_file.php"; // Different functions to handle the zip file EXTRACT Read etc.... // here some (pseudo/example)code set_time_limit( intval(60 * 5) ); // give it 10 minutes, you may also increase this echo "<pre>"; readXML(); exit; //******************************************** /** ----------------------------------------------------------------- * @desc Finde XML/ZIP, entpacken und einlesen der daten */ function readXML() { $opfile = new OPfile(); // dbg is a wrapper for "echo", so you can ignore it via one Flag in op_tools echo "DOC ROOT: ".$_SERVER['DOCUMENT_ROOT']; // Set your path here ... $ropa=dirname($opfile->GetTheRoot())."/"; //opfile $ropa=$ropa . "demo/"; echo "ROOT: ".$ropa; $modpa=$ropa; $projpa=$ropa; $origfolderfrom=$ropa."import/ftpin/"; $ftptemp=$ropa."import/temp/"; $folderfrom=$origfolderfrom; // Find the ZIP/XML File in the FTP Folder // $fileinfo will be used by following functions. you can add more information if needed $fileinfo= $opfile ->GetUpload($origfolderfrom ); // return = assoc-array $fileinfo ['temp']=$ftptemp; $fileinfo ['folder']=$origfolderfrom ; // Extract or Copy the Files, so we can prozess the xml info if ($fileinfo['type'] =='zip') { // if it is ZIP , extract it to temp $xmlfilename= $opfile ->ExtractZIP($fileinfo); echo "<p> XML ist:".$xmlfilename."</p>"; echo "<p>Kopiere: " .$fileinfo ['folder'].$xmlfilename ." <br> nach: ". $ftptemp.$xmlfilename."</p>"; }else{ // if it is XML copy it to temp $xmlfilename = $fileinfo['file']; copy ($fileinfo ['folder'].$xmlfilename , $ftptemp.$xmlfilename); echo "<p>Kopiere: " .$fileinfo ['folder'].$xmlfilename ." nach: ". $ftptemp.$xmlfilename."</p>"; }//if // XML File from temp folder $stat = $opfile ->LoadXML($ftptemp.$xmlfilename); $path = $ftptemp.$xmlfilename; if (file_exists($path)) { $xml = simplexml_load_file($path); echo "<p>Erfolgreich geladen <br></p>"; $nodeList = $xml->xpath('//immobilie'); } // you can access the XML Object by: $opfile ->XMLdata; if ($stat == true) { // read basic infos form XML File $xinfo= $opfile->decodeUTF8($opfile ->XMLinfo()); // print_r($xinfo); echo "Objekte im Import: ".$xinfo['anzimmo']."<br >"; echo "Anbieter ID: ".$xinfo['anbieterid']."<br >"; }else { // Error in Processing. Stop the run. $xinfo['anzanbieter'] =0 ; $xinfo['anzimmo'] =0; echo "Fehler In der XML Datei"; // exit can be put away. The For Loop does not run with azi=0 exit; }//if $azi=intval($xinfo['anzimmo']); // get the number of Objects in archive // save our start time, so we can find which pages should be removed $started = time(); // keep track of how many changes we've made so we can report at the end $numChanged = 0; $numAdded = 0; $numTrashed = 0; // the parent page of our items: /about/what/ is a page from the basic profile // update this to be whatever parent you want it to populate... $parent = wire('pages')->get('/about/'); if(!$parent->id) throw new WireException("Parent page does not exist"); for ($ni=1; $ni<=$azi;) { //$xinfo['anzimmo'] echo "<h2>=======Object=".$ni."======</h2>"; $idata = $opfile->GetOneImmo( $ni, $xinfo); // $idata stores all the values in the Array for current Object $action=$idata['verwaltung_techn'] ['aktion']['aktionart']; if ($action =='') { $action="ADD"; }//if $page = wire('pages')->get($idata['verwaltung_techn']['objektnr_extern']); if($action == 'ADD') { if(!$page->id) { $page = new Page(); $page->parent = $parent; $page->template = 'immo'; // template new pages should use $page->name = $idata['freitexte']['objekttitel']; echo "Adding new page:".$idata['verwaltung_techn']['objektnr_extern']." Titel ".$idata['freitexte']['objekttitel']." <br>"; $numAdded++; } // print_r($idata); // now populate our page fields from data in the feed $page->of(false); // ensure output formatting is off $page->title = $idata['freitexte']['objekttitel']; $page->summary = $idata['freitexte']['dreizeiler']; $body = "<h2>".$idata['freitexte']['dreizeiler']."</h2>"; $page->body = $body; } if($action == 'CHANGE') { echo "CHANGE"; if(!$page->id) { $page = new Page(); $page->parent = $parent; $page->template = 'immo'; // template new pages should use $page->name = $idata['freitexte']['objekttitel']; echo "<h2>Change page data:</h2>".$idata['verwaltung_techn']['objektnr_extern']." Titel ".$idata['freitexte']['objekttitel']." <br><br>"; $numChanged++; } } if($action == 'DELETE') { echo "DELETE"; $numTrashed++; foreach($changes as $change) echo "\nUpdated '$change' on page: $page->name"; } $ni++; }//for Object echo "\n\n$numAdded page(s) were added"; echo "\n$numChanged page(s) were changed"; echo "\n$numTrashed page(s) were trashed\n"; }//funktion ?>
  12. Hi, On a project I'm working on I have a select options field that you can select what type of content you're posting. It has the following options: 1=Article 2=Q and A 3=Visual snippet 4=Gallery 5=List The assigned template has an icon (file-text-o), which is great for articles but maybe not so for galleries. Is it at all feasible/possible to change the assigned icon based on a field value within a page? Or even append a page title in the tree with an icon based on a field value?
  13. Hi, I'm new to PW and still a novice in PHP. I was just wondering how does one access PW within a function? do I pass the entire $page variable to getTitle()? or do I use global $page within the function...I'm confused.. Especially considering there must be a performance penalty for passing entire page variable when I only need a few variables from it (for example $page->long_title, $page->menu_title, $page->short_title). function getTitle() { $long_title = $page->long_title; $title = !empty($long_title) ? $long_title : $page->title; return $title; }
  14. I created fieldtype "select" for template (0:=Prepared, 1:=Done) And need to make for list of pages with this template value for this fieldtype to "1" from. There are to many pages to do it manualy. How to make it?
  15. Hi everyone, sorry if this is a duplicate question but I cannot seem to find the proper way to achieve what I want. I need a way to store and retrieve the datetime of users' last login so that I can display a list of pages that have been updated since the user was last logged in. I've been trying to accomplish this with hooks but I can't figure out where to store the login date. I feel like I should be able to do this with just $user->get and $user->set, but it seems like these only hang around during the current session? Do I need to extend the User class in a module or is there another way to add a field to the User class? Thanks in advance!
  16. Hi, I'am at a loss ... I was absolutely certain that something like $wireData->has('key=value') or $wireData->is('key=value') existed. But it does not. has only takes a key name not a selector, and is does not exist on WireData. Is there another WireData method I am missing to accomplish this? I know there are simpler ways to get if a field has a certain value, but I need it as a selector string. Thanks!
  17. How can I get the index type of a mysql database table with pw-api? The Following doesn't work. Why? $table = 'pages'; $column = 'pages_id'; $sql1 = $db->query("SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '$table' AND COLUMN_NAME = '$column'"); $options = array(); while ($row = $sql1->fetch_array()) $options[] = $row; var_dump($options); // return empty array
  18. Hi everyone, I have a problem using the processwire api in my own system. I use it to configure some special pages (texts, images and so on). Everything is working fine so far. Except when I'm doing a POST-Request (a search for example). The request has nothing to do with processwire. As soon as I do a POST-Request I'm getting the following error-message: Fatal error: Call to undefined method Session::addHookAfter() in MY_PROCESSWIRE_PATH\wire\modules\Session\SessionLoginThrottle\SessionLoginThrottle.module on line 50 Error: Call to undefined method Session::addHookAfter() (line 50 of MY_PROCESSWIRE_PATH\wire\modules\Session\SessionLoginThrottle\SessionLoginThrottle.module) This error message was shown because site is in debug mode ($config->debug = true; in /site/config.php). Error has been logged. Here is my desperate attempt to workaround the problem //dirty workaround ahead $postData = $_POST; //save post data $_POST = array(); //clear $_POST include("../../processwire/index.php"); //include doesn't throw error $_POST = $postData; //write it back So what's the reason for the problem? Thanks in advance!
  19. Hi all. I have pages (templates) that are only accessible to certain users. Now I need to get all users that have view access to specific pages (they will get email when page updates). I thought of something like this: $template = wire('templates')->get($p->template); $roles = $template->getRoles(); $users = wire('pages')->find('template=user, roles=' . $roles); But it looks like getRoles() doesn't returns the roles for that template. Roles is an empty PageArray. What is wrong or is there another way to get those users?
  20. Hi Guys, I am working on a project for a startup company. I will be building a portal for users to access company related information. I am required to connect the portal to an LMS which is a learning management system. I am looking to hire someone to assist with the SSO since I have a lot of work already with the portal. The portal will be built on ProcessWire and require user management. Please message me if you are interested in helping out. I would like to get some quotes before the weekend is over. Looking to start ASAP on this project. Let me know if you have any questions. Also note, once we have the SSO out of the way, more work may arise from this project, since our timeline is somewhat short. Thanks!
  21. Hello, I remember recently using processwire's built-in json API in one of the dev builds. I can't seem to find any kind of documentation of that now. Since I switched my machine, I can't even find that code again.(I've been searching for hours) Can anyone please point me or provide me any clue about the above said json api? It worked something like this: If you need to find any pages using template basic-page, you can get it as follows: http://example.com/processwire/?template=basic-page hit above and it'll return the json output. Thanks.
  22. Hello PW'ers, I'm a PW newbie and my first post in this forum. In the last years i was a 'hardcore' Drupal user, but i'm confused about the 'bloated' code. Make your own Drupal-theme is a hell. A few days ago I find PW. My first impression, HOW WORKS THIS??? Reading many posts in this forum, and a lot of searching on the net for good simple tutorials to understand PW. Today follow a first 'beginner' tutorial, finding in Docs of the PW-site. Wauw!! Thats an amazing CMS/CMF. I searching for a tutorial how make a select/dropdown/tag-list (similar as 'Taxonomies' in Drupal) and find it: http://wiki.processwire.com/index.php/Page_Field I try it succesfully. Ok, I have a question: I found a good tutorial in this forum how make a simple form (thanks @soma!). But how know with options a module have? Example: $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form->append($field); In the above code, i see a label, attr, required But how can I know with options are available for a module? PS: Sorry for my bad english Regards, Christophe
  23. I really wanted to create this post with some sample code to show that I at least tried to figure it out on my own first, but I'm really struggling with how hooks are even written. I know it's a very simple context for anyone who's already using them (and hopefully it will be for me, soon), but this is my first time. What I'm trying to achieve in this attempt is to verify/change the name and title fields of a page, of one specific template with one specific field, whenever the page is saved. Initially, I am using the Family / Name Format for Children to skip the name/title/confirm save page when an author creates a new page in my site using kongondo's ProcessBlog module. In English, I want to: Detect when a page of template blog_page is saved with the blog_categories field value of Swatch, and replace the title and name string with a concatenated version of the following fields (from the same page): blog_date, createdUser, blog_brand and blog_name. From what I've read so far, I should build this hook into site/templates/admin.php, and I should use the saveReady() and maybe saveField() hooks. Other than knowing I need to define a custom hook, I really haven't got any idea of where to go from here. Here's my mangled first attempt at coding my hook. Hopefully you'll be able to tell how I might be misunderstanding this from the following: $pages->addHookAfter('saveReady', $this, 'myPageRename); public function myPageRename($event) { } I'm afraid that's really as far as I've gotten because I have no idea what I'm doing. I try to follow examples but they feel really far removed from context for me. Thanks for any light that can be shed on this!
  24. public function init() { // add a hook after each page is saved $this->pages->addHookAfter('saved', $this, 'populateDefaults'); } /** * Populates model defaults after save for corresponding blank fields. * */ public function populateDefaults($event) { $page = $event->arguments('page'); if($page->template != 'vessel') return; //$this->message("hi {$page->model->hulls}"); if($page->model && !$page->hulls && $page->model->hulls) { $page->set("hulls", $page->model->hulls); $this->message("hi $page->hulls {$page->model->hulls}"); } } This sort of works; the message echoed is "hi 1082 1082". When I set the hulls to null in the above code, it then goes back to "hi 1082". However, it doesn't update the select input in the edit screen, and the "Missing required value" error for that field remains... Also the message shouldn't even be showing if $page->hulls is set... How can I get it to update the field value and the input?
  25. I have a page field 'make', which consists of manufacturer template pages. A new page can be created from that field, but I currently have that functionality disabled, since following that field is another page field 'model' with a custom selector, 'parent=page.make, template=model'. So since the model field parent is dynamic, new pages cannot be created from the field, as the first requirement for that feature is that a single parent and template be pre-selected... Is there some way I can hook into the options there and add an 'Add New' option at the bottom, opening up the new model in a modal? Thanks.
×
×
  • Create New...