Leaderboard
Popular Content
Showing content with the highest reputation on 03/07/2017 in all areas
-
@modifiedcontent Say you have the following form <form method="post"> <input type="text" name="name"> <input type="textarea" name="message"> <input type="submit" name="submit"> </form> You can save it to a page like this <?php if($input->post->submit) { $p = new Page(); $p->template = "template_to_save_form"; $p->parent = $pages->get("/parent-page/"); $p->title = $input->post->name . " - " . date("Y-m-d"); $p->submitted_by = $input->post->name; $p->message = $input->post->message; $p->save(); } You'll have to create the template, its fields and the parent page first. Also before saving the page make sure to validate/sanitize the input. <?php $p->submitted_by = $sanitizer->text($input->post->name); // instead of just $p->submitted_by = $input->post->name; https://processwire.com/api/ref/sanitizer/4 points
-
Looks like an attack on a WordPress site with a small wave. Maybe this is an interesting read for it: https://perishablepress.com/protect-post-requests/3 points
-
This is amazing and so easy to skin, I noticed a few CSS errors, I will put them on GitHub Great work Ryan!3 points
-
Thanks -- Ah, I see why I confused $content and $bodycopy ... $content worked perfectly. I think I started with the blank processwire profile, but not sure how I would find this... I'll keep learning... everything's working fine for now though.2 points
-
Hey man! We all here will do our best to help you, but you should provide at least some details) Like what profile did you install and started from. It just might be that you do use the default profile, and the the name of the variable for main content should be $content and not $bodycopy. But that is a just a wild guess. Be more specific, provide some details and get the best answers on the web from the most awesome community on the planet. Have fun with ProcessWire!2 points
-
This module now works with the core Page Clone module, so now when you "Copy" a page and edit the title, the name will also change based on the config settings of this module. I think this is really important, because the current behavior of the clone module will likely result in incorrect names/urls for the new page - I don't think you can rely on site editors to manually edit page names to match titles. There is currently one issue where it doesn't work for the names of other languages on a multi-language site. I believe this is a bug in the clone module (https://github.com/processwire/processwire-issues/issues/207), but if Ryan says it isn't a bug, then I'll add a workaround in this module.2 points
-
Ok, so based on the error, it's clear it's an issue with the ImageExtra module. Make sure you are using the latest version of that module and if you're still having problems you may need to request support in its forum thread, although it might be as simple as disabling that module on this video field.2 points
-
Since you not know, you could step-by-step by checking what $page is, what $some_user_page is, et cetera. First check your own data, if you are sure that the pages are what you expect them to be and the config of the templates is correct you should look deeper.2 points
-
To get url with scheme and hostname use $page->image_field->httpUrl(); It maybe would make sense to provide modifying output of Pagefile::url() via arguments similar to Page::url() (just to mention: a page is not a file!)2 points
-
Just be careful not to build a mystery meat navigation.2 points
-
There were a few talks about user avatars here on the forums. Like it means something. I never thought it does. But today I suddenly realized how far the right avatar can take you. I was just testing something in the incognito mode in chrome and... here he is, mr. @kongondo himself! I know, I know, you can say it is only someone that closely resembles @kongondo, but does it matter? If he could make it into my subconscious that far, he could easily penetrate the browser .2 points
-
2 points
-
2 points
-
This module (http://modules.processwire.com/modules/import-external-images/) works for images embedded into HTML with full http urls, bit should be easy to modify to support a local path instead.2 points
-
2 points
-
MarkupGoogleRecaptcha Google reCAPTCHA for ProcessWire. This module simply adds reCAPTCHA V2 or Invisible reCAPTCHA to your form. How To Install Download the zip file at Github or from the modules repository Drop the module files in /site/modules/MarkupGoogleRecaptcha In your admin, click Modules > Refresh Click "install" for "MarkupGoogleRecaptcha" Official install/uninstall doc: http://modules.processwire.com/install-uninstall/ API You must create an API key prior to use this module. Goto https://www.google.com/recaptcha/admin to create your own. Next, add the API keys information to the module's settings. Usage Call the module : $captcha = $modules->get("MarkupGoogleRecaptcha"); Call $captcha->getScript(); somewhere to get the javascript used by reCAPTCHA Render reCAPTCHA in a standard HTML <form></form> by calling $captcha->render() or Render reCAPTCHA in an InputfieldForm by passing as argument your form to the render function: $captcha->render($form) Call verifyResponse() to get the result. It return TRUE if the challenge was successful. Example Using ProcessWire's form API : $out = ''; $captcha = $modules->get("MarkupGoogleRecaptcha"); // if submitted, check response if ($captcha->verifyResponse() === true) { $out .= "Hi " . $input->post["name"].", thanks for submitting the form!"; } else { $form = $modules->get("InputfieldForm"); $form->action = $page->url; $form->method = "post"; $form->attr("id+name", "form"); $field = $this->modules->get('InputfieldText'); $field->name = "name"; $field->placeholder = "name"; $form->add($field); // CAPTCHA - our form as argument, the function will add an InputfieldMarkup to our form $captcha->render($form); // add a submit button $submit = $this->modules->get("InputfieldSubmit"); $submit->name = "submit"; $submit->value = 'Submit'; $form->add($submit); $out .= $form->render(); // include javascript $out .= $captcha->getScript(); } echo $out; Example using plain HTML Form : $captcha = $modules->get("MarkupGoogleRecaptcha"); // if submitted check response if ($captcha->verifyResponse() === true) { $out .= "Hi " . $input->post["name"] . ", thanks for submitting the form!"; } else { $out .= "<form method='post' action='{$page->url}'>\n" . "\t<input type='text' name='name'>\n" . $captcha->render() // render reCaptcha . "\t<input type='submit'>\n" . "</form>\n"; $out .= $captcha->getScript(); } echo $out;1 point
-
Pia - Pageimage Assistant Hello, today I can tell you that Pia Ballerina want to assist you with Pageimages and that can become really helpful! . . . Pia, in its current state, version 1.0.0, provides: a GUI (the module config screen) for quick and easy changes to the sitewide Pageimage default options an alternative way for calling the Pageimage resizing methods with PW selector strings three new methods as shortcuts to the resizing functions a new method called retinafy and its alias hiDPI, (introduced in version 0.2.0) . . . 2) Instead of ->width(), ->height(), ->size() you can call ->pia() now. With a PW selector string you tell Pia what image variation you want to have : . $image->pia("width=100, quality=80, sharpening=medium")->url; . If you want process ->width() just define width. If you want process ->height() only define height. If you want process ->size() just define width and height. If you want process ->size() with equal values for width and height, just define only size, or use the alias square: . $image->pia("width=480")->url; $image->pia("height=320")->url; $image->pia("width=400, height=300")->url; $image->pia("size=350")->url; $image->pia("square=350")->url; . So, yes, - I see. Now you may think: "Ok, nice looking girl, - and she can dance very well, - but for what should it be good that she is involved here? My very old buddies width, height and size - and me, - we don't need any Ballerinas between us!" . Yeah, I see what you mean. But this above is not what Pia is good for, this is just a little warming up for you. . In some cases one need to specify more than just width and / or height. If it comes to that you need explicitly populated options with the individual pageimages, Pia will become faster and more comfortable at some point. Also the code is looking more readable with Pia, at least to me: . // regular style #1: $image->width(800, array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong")); // or regular style #2: $options = array("upscaling" => false, "cropping" => true, "quality" => 80, "sharpening" => "strong"); $image->width(800, $options); // now lets Pia dance: $image->pia('width=800, upscaling=0, cropping=1, quality=80, sharpening=strong'); $image->pia('width=800, upscaling=off, cropping=on, quality=80, sharpening=strong'); . For me it is that not only Pia begin to dance, my fingers do so too when writing selector strings instead of the regular array code. . Ok, last thing before we can go to stage: "You already may have noticed that Pia accepts few different values for boolean expression, yes?" for TRUE you can write these strings: "1, on, ON, true, TRUE, -1" for FALSE you may use one out of "0, off, OFF, false, FALSE" Ready? Ok, lets go to stage. . . . 3) Pia provide three new methods as shortcuts. This means that when using one of the shortcuts you have pre-populated options, regardless of the sitewide default settings: crop :: does what the name says contain :: is equal to the regular method: ->size($width, $height, array("cropping" => false)) cover :: this, Pias third child, is a new kid on the block . Let's have a closer look and compare it. We use Pias image from above as source for this example. (It's dimensions are 289 x 400 px) . . * crop $image->crop('square=100'); . it is 100 x 100 px and the name is: pia-ballerina_titel.100x100-piacrop.jpg . . . * contain $image->contain('square=100'); . it is 73 x 100 px and the name is: pia-ballerina_titel.100x100-piacontain.jpg . . . * cover $image->cover('square=100'); . it is 100 x 139 px and the name is: pia-ballerina_titel.100x139-piacover.jpg . . . Ok, you got it? . "Crop" crop out the area, "Contain" fits the image into the area, and "Cover" calculates the needed dimensions for the image so that the area is completly covered by it. . Following is a link with lots of those crop-, contain-, cover- variations. I have stress-tested it a bit: much variations . ---------- . . Later Additions: . * contain with option weighten Since version 0.0.6 contain can take an additional param called "weighten". (read more here) . . . * retinafy Since version 0.2.0 retinafy is added. It returns a markup string, e.g. a HTML img tag, where placeholders are populated with property values from the pageimage. Default properties are: URL, WIDTH, HEIGHT, DESCRIPTION. The method also can take an optional array with CustomPropertyNames. You also can use the alias HiDPI if you like. (read more here) . . ---------- . . You can get the module from the modules directory or from the repo on Github: . git clone https://github.com/horst-n/PageimageAssistant.git your/path/site/modules/PageimageAssistant . . Bye! . Classical ballet performance at the Aalto Theatre in Essen, in the context of the Red Dot Award ceremony 26 June 2007, Act III, Sleeping Beauty, the wedding reception Photos: Horst Nogajski - www.nogajski.de1 point
-
As fas as I know, currently there is no way for a module developer to include a changelog in a way that enables us to check out the changes in the admin before upgrading.1 point
-
Last week’s post indicated we may have the first [beta] version of the Uikit admin theme ready, and I’m glad to report that we’ve now got it ready for download on GitHub. In this post, we’ll describe what’s new, how to install it, and how to develop with it. https://processwire.com/blog/posts/processwire-3.0.54-and-adminthemeuikit/1 point
-
I get the feeling that the Gilbert Burnett you are seeing is actually the $headline. I bet that $bodycopy is not being output/echo'd within main.inc at all.1 point
-
thanks for the blazing fast answer adrian. I had refresh the page, but my test was running again and again, so didn't see that. Merci !1 point
-
You do need to save. Not sure how your tests are set up, but if you set the email and then get it straight after, it will appear changed, but if you reload the page, it won't have stuck unless you save.1 point
-
Welcome to the forums, @michaelriordan! It is all there in the error message. Something gets added to the file you are writing you markup in (<!DOCTYPE html> in particular) . It seems like you have started with a profile that uses delayed output. And the contents of _main.php are appended after your code. You can check site/config.php if it contains something like $config->appendTemplateFile = '_main.php'; to make sure. Start with a blank or beginner profile instead. If that did not help please provide more details.1 point
-
It's better in a way. You have SSL support, which could be a pain in the ass to configure and maintain. Server Pilot free plan does not have SSL enabled. So, $12.49 one time payment is a very nice deal.1 point
-
@Macrura You might not need the json export/import functionality anymore. See this new module1 point
-
Hi @phil_s Also check this blog post from Ryan Filtering out common WordPress files1 point
-
I do not know much about ServerPilot, but I think it is "just a tool" to manage "classic" linux servers (FAQ: http://gopanel.io/faq): "With goPanel you can install/manage/configure on Unlimited servers (VPS or Dedicated)" also: What Linux distributions do you support? Ubuntu 14.04 (LTS), 14.10, 15.04, 15.10, 16.04, 16.10 CentOS 6.x, 7.x Amazon Linux 2016.03 Red Hat Enterprise Linux 6.x, 7.x Debian 7 and 8 As @Sérgio pointed out: "Looks like a timesaver" so you do not have to cli to setup a lot of features usually required, and it runs on your Mac doing the cli work for you via its GUI.1 point
-
Click "Clone or Download" on the Github page, then right-click on the "Download Zip" link and paste that into the "Add Module from URL" install option.1 point
-
Looks like a timesaver app, @szabesz! I think I'm gonna buy it. Thanks for the tip!1 point
-
Now you do Me neither, but I do know getting familiair with Tracy saved a lot of my time the last year.1 point
-
1 point
-
1. specify a template 2. check if the parent you have set exists $page->of(false); $page->template = 'whatever'; $page->parent = $some_user_page; if ($page->parent->id && $page->template->id) $page->save(); else die('Something went wrong'); or use a debugging tool.1 point
-
Done! I lost one image field (bummer) that was using the fieldtypeimageextra field. I discovered which field it was from the SQL database, but I couldn't change the image type in the admin interface because I kept getting an error. On the up side, the error messages are all gone and it looks like everything is working fine.1 point
-
1 point
-
I advise you post this in ProCache support forum. Ryan's support is something what is even more valuable than the module itself. I am sure you will find the answer there.1 point
-
1 point
-
Hey @Peter Knight - not sure how you normally install modules, but I would suggest in general going for the class name, upload, or url to zip approaches, which avoid this possibility. Manually downloading and unzipping means you have to watch for this.1 point
-
1 point
-
I'd not expect to much of the project as it's been in the state the website does show for about a year now? Can't remember correctly.1 point
-
@modifiedcontent Actually it's pretty funny you're asking this right now. Some hours ago I opened a feature request regarding this because at the moment it's not possible to swap the order without using regex.1 point
-
For the topic how to import / batchimport content into PW you will find many posts with examples in the forums, - so I will focus on your special issue with your images that are linked to "./images/...." in your htmlContent. Assumed, you use an importer script, that reads the following from a source: title / name of an entry html content images basenames Assumed, that the importer script can access the imagefiles / knows where they are kept for the import. And assumed that you have created a template with fields for those pages you want to create during the import. Then you will come to a point, where you programatically create a new page: $p = new Page($myTemplateObject); $p->of(false); $p->title = $theEntryTitle; $p->parent = $theParentContainerPage; $p->save(); Now you can add / import your images to an imagefield: foreach($imagebasenameArray as $basename) { $p->imagefield->add($directorypathToImages . $basename); } Now all images of that entry resides in /site/assets/files/{PAGE_ID}/. And you have to modify your html-content to match this: $p->body = str_replace("./images/", $config->urls->files . $p->id . "/", $htmlContent); $p->save(); This way you will have the most possible flexibility with your pages, I think. Please note: written in the browser, - may have bugs, - is meant as pseudo code.1 point
-
I think renderReady() is the right place to load any JS dependencies.1 point
-
Thanks for your comments, I also reviewed how Ryan implemented it, from there come my idea. I currently use a Latte Engine Module, but for 90% of the web pages my clients need is too much of the view/controller model, it's a lot of work for simple things. That's why I like what Ryan did, but I need regions that be more versatile in defining where to place it in the document, that not use the classes/ids directly and be less complicated in terms of the number of directives and tags variants. Just do it simple. An illustration example: https://processwire.com/talk/topic/15582-markup-regionsidea-for-another-placement-attribute/1 point
-
I would also love to see this - I think it would be great if we could define it in a Github repo changelog.md file and have the automatically imported into the text in the modules directory, and perhaps even displayed in the module info within a PW install. Perhaps it would even be nice to have a way to add a flag about breaking changes that would show up in the ProcessWire Upgrades module so you are warned before upgrading. @ryan - any thoughts on this? I'd be happy to work on it - obviously I could do the PW side of it from the repo, but would need access to the php files for the modules directory to make that side of things work.1 point
-
I may be alone with this but I feel more productive without CSS frameworks. A small grid is OK but the rest is better to be custom. There is always something I need differently done and then the framework only hinders me.1 point
-
Greetings Everyone, ************************************************* ************************************************* EDIT NOTE: This post started as a work-in-progress discussion as I was working out the elements of a successful form. After contributions from participants in this discussion, the code below has been tested and works well. You can use the code as shown below in your ProcessWire templates! Feel free to follow up with additional quesations/comments! ************************************************* ************************************************* I have successfully built front-end forms with ProcessWire to add pages via the API. It works great -- until I had to include image uploads along with the "regular" form fields. Then it temporarily got a bit complicated. In this discussion, I show how to handle front-end submissions in ProcessWire with the goal of allowing us to create pages from custom forms. I then go a step further and show how to use the same form to upload files (images and other files). I'm hoping this discussion can illustrate the whole process. I know a lot of people are interested in using ProcessWire to do front-end submissions, and my goal for this discussion is to benefit others as well as myself! First, here's my original contact form (no file uploads): <form action="/customer-service/contact/contact-success/" method="post"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <button type="submit">Submit</button></form> And here's the "contact-success" page that picks up the form entry to create ProcessWire pages: <?php // First, confirm that a submission has been made if ($input->post->contactname) { // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // Send all form submissions through ProcessWire sanitization $title = $sanitizer->text($input->post->contactname); $name = $sanitizer->text($input->post->contactname); $contactname = $sanitizer->text($input->post->contactname); $email = $sanitizer->email($input->post->email); $comments = $sanitizer->textarea($input->post->comments); // Match up the sanitized inputs we just got with the template fields $np->of(false); $np->title = $contactname; $np->name = $contactname; $np->contactname = $contactname; $np->email = $email; $np->comments = $comments; // Save/create the page $np->save(); } ?> This works great! After submitting the form, we go to the "Success" page, and new submissions show up in the ProcessWire page tree right away. Excellent! Now I need to add a photo field. I altered the above form so it looks like this: <form action="/customer-service/contact/contact-success/" method="post" enctype="multipart/form-data"> <p><label for="contactname">Name:</label></p> <p><input type="text" name="contactname"></p> <p><label for="email">E-Mail:</label></p> <p><input type="email" name="email"></p> <p><label for="comments">Comments:</label></p> <p><textarea name="comments" cols="25" rows="6"></textarea></p> <p>Click the "Select Files" button below to upload your photo.</p> <input type="file" name="contact_photo" /> <button type="submit">Submit</button> </form> And here's the updated "contact-success" page: <?php // First, confirm that a submission has been made if($input->post->contactname) { // Set a temporary upload location where the submitted files are stored during form processing $upload_path = $config->paths->assets . "files/contact_files/"; // New wire upload $contact_photo = new WireUpload('contact_photo'); // References the name of the field in the HTML form that uploads the photo $contact_photo->setMaxFiles(5); $contact_photo->setOverwrite(false); $contact_photo->setDestinationPath($upload_path); $contact_photo->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif')); // execute upload and check for errors $files = $contact_photo->execute(); // Run a count($files) test to make sure there are actually files; if so, proceed; if not, generate getErrors() if(!count($files)) { $contact_photo->error("Sorry, but you need to add a photo!"); return false; } // Do an initial save in the ProcessWire page tree; set the necessary information (template, parent, title, and name) $np = new Page(); // create new page object $np->template = $templates->get("contact_submission"); // set the template that applies to pages created from form submissions $np->parent = $pages->get("/customer-service/contact-us/contact-submission-listing/"); // set the parent for the page being created here // Send all the form's $_POST submissions through ProcessWire's sanitization and/or map to a variable with the same name as the template fields we'll be populating $np->title = $sanitizer->text($input->post->contactname); $np->name = $np->title; $np->contactname = $sanitizer->text($input->post->contactname); $np->email = $sanitizer->email($input->post->email); $np->comments = $sanitizer->textarea($input->post->comments); $np->save(); // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->contact_photo->add($pathname); $np->message("Added file: $filename"); unlink($pathname); } // Save page again $np->save(); ?> <p>Thank you for your contact information.</p> <?php return true; } else { ?> <p> Sorry, your photo upload was not successful...</P> <?php } ?> Replace the field references with your own field names, make sure to change the various paths to match yours, and change the various messages to be what you need for your project. Read the entire discussion to see how we worked through getting to the solution shown above. Thanks, Matthew1 point
-
Sorry about that - you must be running PHP 5.3.x. I had some code in there that was 5.4+ only. I have made a fix so that it will work on 5.3. Please try again with the latest version on Github.1 point
-
There is one ) too much, but it also gives a 500 Internal server error edit: echo "identical" was missing ; that caused the 500 Internal error. It seems to work find when you remove on ) and add a ; // could be this. if(count(array_diff($array_1, $array_2)) === 0) { echo "identical"; } This one is not that short but will do the job $wa1 = $pages->find('template=foo'); $wa2 = $pages->find('template=bar'); $wa3 = $pages->find('template=foo|bar,sort=name'); $wa4 = $pages->find('template=foo|bar,sort=-name'); $wa5 = $pages->find('template=foo|bar|foobar'); echo "compair: wa1 and wa2 = "; echo count($wa1) >= count($wa2) ? count($wa1->not("id=$wa2")) : count($wa2->not("id=$wa1")); echo "<br>"; echo "compair: wa3 and wa4 = "; echo count($wa3) >= count($wa4) ? count($wa3->not("id=$wa4")) : count($wa4->not("id=$wa3")); echo "<br>"; echo "compair: wa3 and wa5 = "; echo count($wa3) >= count($wa5) ? count($wa3->not("id=$wa5")) : count($wa5->not("id=$wa3")); echo "<br>"; Output (where 0 means identical) compair: wa1 and wa2 = 3 compair: wa3 and wa4 = 0 compair: wa3 and wa5 = 9 (I have 3 pages with template foo, 3 with template bar and 3 with template foobar)1 point
-
I think that Pw returns null if a POST variable isn't set. So this should also work: if (!is_null($input->post->list)) {} if ($input->post->list !== null) {} // Simplest but be careful when list contains the value '0' - this is casted to false if ($input->post->list) {} You get the warning from PHP if your array is empty and you want to iterate over it - that's why you always should first check if the variable is set / contains values. Quote from the docs: $input returns NULL if you access a variable that doesn't exist (no need to use isset() like with PHP's superglobals) http://processwire.com/api/variables/input/1 point
-
You can reuse fields between templates (so you don't need different body field for each of your templates), but using same field multiple times on same template is pretty confusing concept to be honest. It's like having twins and giving them same name.1 point