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. I want to make a little module that tracks pageviews. This is my first module. I'm starting with a copy of helloworld.module. I already created the template pageviews and pageview manually, but I'll add their creation into the module later. Here's what I have: public function viewTracker($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; if($page->template == 'vessel') { $r = new Page(); $r->template = 'pageview'; $r->parent = wire('pages')->get('/viewtracker/'); $r->user = $user->name; $r->vessel_id = $page->id; $r->name = $user->id . $page->id . date('YmdHisu'); //$r->status = $r->status | Page::statusLocked; $r->save(); } // add a "Hello World" paragraph right before the closing body tag $event->return = str_replace("</body>", "<p>Hello $user World!</p></body>", $event->return); } but the $user variable isn't coming through. How can I access the logged in $user? Edit: Got it. Replaced the $user with $this->user..... public function viewTracker($event) { $page = $event->object; // don't add this to the admin pages if($page->template == 'admin') return; if($page->template == 'vessel') { $r = new Page(); $r->template = 'pageview'; $r->parent = wire('pages')->get('/viewtracker/'); $r->user = $this->user; $r->vessel_id = $page; $r->name = $this->user . $page . date('YmdHisu'); $r->status = $r->status | Page::statusHidden; $r->save(); } }
  2. User input should be sanitized... If I use CKEditor at PW admin to change a field value it should be sanitized by CKEditor Advanced Content Filter (ACF) and HTML Purifier (activated at CKEditor Settings). At the moment I play with frontend edit solutions. Frontend form (based on form api and PW inputfields) with a custom save process (set and save field value with PW api) Inline edit (jquery plugins jEditable, x-editable, jinplace) and a custom save process (see above) So the values not saved by the PW admin / backend process and would be saved without sanitizing in both ways above... right?
  3. Hi Guys, So I am working on a project and wanted to get the best advice using the api on the next step. I have two image fields in one template. postimage which holds an image for the article and postimage2 which holds an image for the home page. Basically I want to make it so that when a user uploads postimage and not postimage2 the home page will just pickup postimage instead. If the user does upload postimage2, it should pick up postimage2. What I did: I did add a conditional statement to check if postimage2 was empty to simply default to postimage but I was not seeing any images display. Here is my code: <?php foreach($featured as $featuredp){ foreach($featuredp->postimage2 as $postimages2) { echo"<div class=\"row panel\" style=\"margin:20px auto;\">"; echo"<div class=\"large-4 columns\"><p> <a href='{$featuredp->url}'><img src='{$postimages2->url}' width=\"300\"/></a></p></div>"; echo"<div class=\"large-8 columns\"> <h4>{$featuredp->title}</h4> <p><em>{$featuredp->date}</em></p> <p>{$featuredp->summary}</p> <p><a href=\"{$featuredp->url}\" class=\"button tiny radius\">Read More</a></p> </div> </div>"; $found = 1; } } if ( ! $found ) { echo"<p>Sorry, no posts.</p>"; } ?> Any advice is appreciated? Also any suggestions or workarounds are also welcome!
  4. Hi Guys, I have created a slider using Bootstrap and in Bootstrap the slider image that is first in line is required to have the class active. In creating a repeater for my client to add images, I need to add a conditional statement to check if the item is first in the repeated elements and if it indeed is first, assign active as the class. Not sure what is best practice using a selector and the api to see if the the repeated element is first in the repeater list. Any light? Thanks guys!
  5. To get a page by index number from a PageArray is easy: /* returns a page object */ $pagebyindex = $myparentpage->children->eq(integer $num); Now I needed a function which returns the Index of the page from the siblings. It took me a while to figure this out, and I like to share this here: /* returns an integer */ $indexbypage = $myparentpage->children->getItemKey($page); // or $indexbypage = $page->siblings->getItemKey($page); Found this information in http://cheatsheet.processwire.com/ under section PageArray/WireArray and here: http://processwire.com/apigen/ To get complete information about API this page is your (and my) friend. Have a nice day
  6. Greetings I'm new to PW, and think it's fantastic! Never, ever, have I seen such an amazing CMF! Anyways, to my question: I had set some Hanna Code to render a list of page suggestions on the http404 page, which works perfectly. The problem, however, comes in when I use repeaters, which are page instances. The page suggestion renderer has the following: $suggestions = $pages->find('name|title|summary|body%='.$request); I have a page that is named services-industries, and repeaters with the word services in the name. As such, repeaters appear in the suggestion results-list if applicable to the search. How can I exclude/remove those?
  7. Currently to change the 'summary' description in context of 'basic-page' we would have to do this: // get the template $t = $templates->get('basic-page'); // get the field in context of this template $f = $t->fieldgroup->getField('summary', $useFieldgroupContext = true); // value of the field $f->description = "'basic-page' summary description"; // save new setting in context $fields->saveFieldgroupContext($f, $t->fieldgroup); What I'd like is something like this // get the field $f = $fields->get('summary'); // value of the field $f->set('description', "'basic-page' summary description", $context = 'basic-page'); // save new setting, perhaps optional, because behind // the scenes `saveFieldgroupContext` has been called already? $f->save(); Similar for getting in context: $f->get('description', $context = 'basic-page'); Not only is it more intuitive, but less verbose, in my opinion. What do you think?
  8. I'm developing a site for a client which involves (non-logged in) users submitting resources which other anonymous users can then view or download. The final downloadable resources will be produced by my client from files and text (up to 10 files - pdfs, spreadsheets, images etc) uploaded by the user. So the flow goes something like this: User submits a frontend form containing a description of the resource, eg typical resource may be "Study of sustainability of commercial fishing in area X", along with a number of files, for example, shaded maps (image), spreadsheet of data, word or open document of evidence, and a number of other images. Files and text descriptions are emailed to my client Client reads through and organises the files and text into one or more PDFs. Client creates a new PW page, adds a description of resource, and uploads PDF(s) to the page Users then view the PW page and can download or view the accompanying PDFs Pretty simple kind of scenario. However, I'm conflicted as to how the upload/emailing of images should proceed; I could either: email the uploaded resources (up to 10 of) direct to the client, or use the API to create a PW page, add the uploaded resources to the page, save page, email resources from the page to the client, and then finally delete the page. Option 1 is simple, but there may be issues? - email failure would result in loss of the resources - large email (10 attachments of up to possibly 5Mb each) could be seen as spam? etc. Option 2 is a little more complex but allows resources to be maintained - in case of email failure resources could be downloaded manually I'm looking for suggestions here, which option would you choose to implement, or an alternative path altogether?
  9. What is the difference between $a->add($item) and $a->append($item)? I know there are some speed improvements in 2.5.x (comparing to 2.4) but is there room for more? I'm using caching in templates, I can not use ProCache. Looking at timers in debug mode I see: boot: 0.2262 boot.load: 0.1925 boot.load.fieldgroups: 0.0506 What is going on between loading fieldgroups and load?
  10. I would like to create sets of custom fields that can be added using the API to sites as I need them. For example, if one of my clients has an existing site developed in ProcessWire and needs a blog added, I would like to use the API to add a set of custom fields specific to a blog. As another example, I may need to add a set of custom fields for social media links. Unfortunately, I can't seem to find a resource that lists every property needed for each field type. How do I know which properties to set? Or is there a way to output fields and properties for an existing installation of ProcessWire?
  11. TL;DR : I'm looking to create dynamic forms which will take fields list from given template & create/save pages dynamically. Hello, I've been using PW for a while for creating web applications like ERP systems and similar applications which have tons of forms. So far I've been creating, processing & validating them manually. While researching I found this link which I found to be very helpful. Code given in that example allows user to create a form based on the fields of any page and save it, which is very cool. Based on that code I tried doing something like this: $p = new Page(); $p->template = "mytemplate"; //I've added few fields to this template $p->parent = "/someparent/"; $p->of(false); // make a form $form = $modules->get('InputfieldForm'); $form->method = 'post'; $form->action = './'; // add the page's fields to the form $form->add($p->getInputfields()); // add a submit button to the form $submit = $modules->get('InputfieldSubmit'); $sumit->name = 'submit'; $form->add($submit); // process the form if it was submitted if($input->post->submit){ $form->processInput($input->post); $p->name = date(dmYhisn); $p->save(); } It did create a page but without any data. I know this could be a very stupid thing to try, but I guess it was worth it. More research taught me that probably using ProcessPageAdd module I can create new pages. But I don't know how exactly that works. I'm looking for some guidance about modules & their use on fron-end. Thanks.
  12. Hi everyone, i want to create a user on the fly with sso, i recieve the password already hashed and want to save the user without having the password hashed by processwire afterwards. so far i could leave it rehashed in the database as long as the customer does not want to allow the users to use the direct loginmask. but if that changes, i would be in trouble. so is there a processwire way to do this or do i have to put the user in manually. i know we will have someone intelligent helping me out here
  13. Hey guys, I'm creating a form via the API where a user can create a page and click to "create and duplicate". The idea is that this reloads the form with a GET variable to the page just created, takes the image from that page and also adds it to the new duplicate page. Essentially there may be 4 pages created but they should all share the same file. Would it be necessary to create a new WireUpload on every page creation or is there some way to do the following (or some variation): $duplicate_page->file->add($just_created_page->file); OR $duplicate_page->file->add($just_created_page->file->url); I don't seem to be able to pull this off but perhaps it's because the WireUpload needs to take place on every page creation.. Anyone had any experience with this? Thanks
  14. Hi all, I am building a page that contains a quite complex request form. To do this, I created a page based on a "contact-form" template, and inside this template I put all the code needed to display the form and manage the results. The form is built using PW API, the code is inspired from some examples I found here on the forum. My problem is that I don't know how to insert a text paragraph between the fields, anyone has idea on how to do this? Here's a very simplified version of my code (only two fields displayed), in this case I would like to append a custom paragraph (simple html) between Company and Name fields. The only solution I found is to use an additional field of Fieldset type, without content, and on the label I set the text I need to output. However in the label field I am not able to insert html tags... Any help is very appreciated... Thank you! // create a text input $field = $modules->get("InputfieldText"); $field->label = "Company"; $field->attr('id+name','company'); $field->required = 1; $form_fields[] = $field; // create a text input $field = $modules->get("InputfieldText"); $field->label = "Name"; $field->attr('id+name','name'); $field->required = 1; $form_fields[] = $field; // submit button $submit = $modules->get("InputfieldSubmit"); $submit->attr("value","Send"); $submit->attr("id+name","submit2"); $submit->skipLabel = '4'; // create the form field (also field wrapper) $form = $modules->get("InputfieldForm"); $form->action = "./"; $form->method = "post"; $form->attr("id+name",'contact-form'); foreach ($form_fields as $field) { $form->append($field); } $form->append($submit); // append the form in $out variable $out .= $form->render();
  15. Our web application is restructuring that will seperate content (PW CMF) and logic (PHP Framework), PW will use to manage content easily. Is it possible to get the page data and put it on other PHP Framework?
  16. Hello, I've searched the forums and API page etc, but I've not really found a great deal of information regarding $session->hello = "Hello World!"; etc. I know what it does, but I don't know the technicalities of it. By this I mean, is it safe to temporarily store a couple of paragraphs of text in a session variable while a page is redirected for example? e.g $session->quotedText = "A couple of paragraphs of text would go here....."; $session->redirect($someUrl); // Get the stored text from the new page $value = $session->$quotedText; Echo "Quoted text from the previous page... " . $value; I can't see anything wrong with this idea, but I'm probably missing something as I can't seem to find many uses of it? Is this an improper use for session variables? Thanks.
  17. Hi Guys, I have a membership site that I am building. The site is simply composed of user profiles, basically like craigslist personal ads. I need to give the member access to a their profile ad/page for editing of fields located on their ad/page. This access will be given to paid members, once the page has been added by me. The user should have access via a user name and password. They will only be able to edit their ad/pages fields I have with their information. Question 1: Is this possible on ProcessWire? Question 2: Any guidance to where I can start? (Modules, API etc.) Question 3: I have a check box field on the profile ads/pages which I control that allows me to deactivate the page if it is un checked, I also want this to block their access. Can this be done? Any help on this would be great! As always, everyone has been great with helping me find solutions to my questions. Thanks!
  18. Currently we have those to access for example 'pages': // in templates $pages->find('something'); // in functions or classes not extending WireData wire('pages')->find('something'); // in classes extending WireData $this->pages->find('something'); // or even a deprecated old way $this->fuel('pages')->find('something'); I propose to implement yet another way: Wire::pages()->find('something'); // or Wire::config()->debug; // or Wire::input()->urlSegements; It would just be a matter of adding those in the Wire class: public static function input() { return self::getFuel('input'); } public static function pages() { return self::getFuel('pages'); } public static function page() { return self::getFuel('page'); } // and so on ... Perhaps it's just aesthetics, ... for my eyes it's definitely way more pleasing. What do you think?
  19. Hi all I have built my own module for processing forms on my site. The module does check to see of the request was forged or not, but I am unable to inset the token name and value into my template. I use Twig for my templates, and this is what I'm calling: <form data-form-ident="contact-form" data-form-token-name="{{ this.session.CSRF.getTokenName() }}" data-form-token-value="{{ this.session.CSRF.getTokenValue() }}"> The output for that is an empty string. Could it perhaps be because I am using Twig? Side note: disabling Twig is not an option as the templates I'm using are very complex - it would be a darn mission to revert to native PHP. (PW 2.4.0)
  20. I was wondering if it's possible to sort user images via the API. I have added an 'images' custom field to the user template and am creating an outside login for artists (users with PW role 'artist') to edit their profile. This involves allowing them to upload images into their 'gallery' and sort them (via drag-n-drop) once uploaded. I was hoping there was some sort of 'sort' field that I could update via the API, but no luck there. I looked into how the admin allows this functionality and it's a bit over my head digging in the images field module. Any help would be greatly appreciated! - Ryan
  21. Hi Guys, Im at a point in my project where I have front end user registration, login capabilities and posting of page capabilities by registered users. The users can also edit their own page. Its pretty much a clean site that is made to function like Craigs list but look like a personal ad site. I have used ryans method for registration, profile control and login. All is good so far! Now in profile template which I call their account management page, a user sees all their pages they have posted. The user can click the link to their page to front end edit their pages content. I would like to also give them ability to unpublish, republish or delete their page. Any thoughts or ideas? The way I invision it, a script checks to see if the user has access to edit the page, which I have done. Then the user can edit via fedI front end editor module. Now I need to display a button unpublish, a button to republish and a button to delete. Any guidance is appreciated.
  22. Basically, I created a site for a client that is a marketing and advertising site for personal ads. The site is intended to allow a user to view the site and if the user wants to post a personal ad to promote their services such as music performing, dancing etc. they can for a small fee. (It's pretty much like back page.com and craigslist.com without the ugly design. More focused to look like a website, with 1 page personal ads.) Currently the site is using the latest Processwire release on Foundation framework. I have users coming to the site and if they decide to post, they click on a link located on the bottom that says post new profile. Once clicked, they arrive to a page that has a form builder embedded form. I am using form builder forms to process the user information and create a new page under the category of their choice. This is working and creates pages quickly for anyone that wants to post an ad. (I was advised not to use this method but due to lack of time, I had to run with Form Builder.) Here is what the system does now: Once a user completes the form, they submit the data and the page is automatically created. The user receives an auto response email with a message asking them to make a payment via a link contained in the auto response email. The link goes to a paypal subscription. Once the paypal subscription is paid, we are manually sending the user a user name and password to manage their page through a front end editor that we setup in Processwire. If they do not pay in 24 hours, we manually delete the page. As far as spam goes, we only have the spam filter enabled on the forms with the turing test question and answer. Here is what I need the system to do: I need help setting up a way to ask for a credit card first, then process the card for the payment, then post the page. I also need help redirecting the user to the newly created page after they have submitted the data through the form builder form. I also need a way to automatically create a user and password and assign it to the newly created page. I am up for any suggestions and welcome all of your input. I would like to essentially make this an automatic type thing. Where all we are doing is checking to make sure things work. Versus manually adding users, manually deleting pages etc. I AM OPEN TO ANY SUGGESTIONS ADVICE, ASSISTANCE ETC. Feel free to PM me as well. If a heavily experienced user feels that they can accomplish this build another method via API etc. please provide some guidance. Again, thanks so much to everyone in this community that has enabled me to learn more, create great things and accomplish tasks, Processwire is truly amazing!
  23. What is the best way of interacting with an external API within ProcessWire: (in this case it's FoxyCart but it could apply to any external API) 1. Store API data (eg customers, transactions) as pages in ProcessWire. Pros: - Can take advantage of PW's admin interface and upcoming Lister module - Better performance/user experience Cons: - Setup time. - Duplication of data (will need to have processes to keep local/remote data in sync) 2. Just pull in the data to the site through the external API as and when it's needed. Pros: - Quick setup - Data stored in one central location Cons: - Cannot use much of the in-built ProcessWire functionality for viewing/managing data. - Potential performance degradation Any thoughts are welcome
  24. Hello community, I am trying to create a field using API. Basically field should have a type of FieldtypeTextarea and InputfieldTinyMCE as inputfield. Here is my code : /* Create new field using API */ $field = new Field(); // Set type as FieldtypeTextarea $field->type = $this->modules->get("FieldtypeTextarea"); // Set inputfield as InputfieldTinyMCE. But no luck $field->set('inputfield', 'InputfieldTinyMCE'); // Name of the field $field->name = 'footer_region'; // Set label $field->label = 'Footer region area'; // Save $field->save(); Above code will create a new field with the type of FieldtypeTextarea. But it want assign InputfieldTinyMCE as the inputfield. Any advise please Thank you
  25. Plase correct me if something is wrong, I'm still learning the processwire way xd. According to the API Docs http://processwire.com/api/variables/page/ $page->path The page's URL path from the homepage (i.e. /about/staff/ryan/) $page->url The page's URL path from the server's document root (may be the same as the $page->path) So I have to migrate a site from development to production server and all the links were messed up. Why? Because I was using $page->path for redirects. Changed redirects to $page->url and Presto! everything works fine. And, When to use $page->path? Use $page->path when importing other page. example $people = $pages->get('/system/people'); $friend = $pages->get($people->path . $input->urlSegment1); Use $page->url when you need a redirect $session->redirect($friend->url);
×
×
  • Create New...