Jump to content

froot

Members
  • Posts

    729
  • Joined

  • Last visited

  • Days Won

    3

Everything posted by froot

  1. Thanks, I made significant progress using the mentioned thread. Still some issues… 1. file sizes Uploading a file (or a total of files) larger than setMaxFileSize (20000000 aka 20MB) defined in my code throws an error as intended and doesn't upload photo_121.tiff - Exceeds max allowed file size Uploading a file (or a total of files) larger than upload_max_filesize (32MB) defined in php settings throws a different error and doesn't upload The uploaded file exceeds the upload_max_filesize directive in php.ini. How to amend this text to be the same as the above? Is this message coming from Apache directly and not PW? Where and how to customize all the notices? Uploading a file (or a total of files) larger than post_max_size (50M) defined in php settings throws no error and doesn't upload 2. file count uploading more files than setMaxFiles (20) defined in PW does upload 20 files. (max_file_uploads in php settings is set to 1000). it lists all the files (how to change that?) and then throws and error: Max file upload limit reached I'd rather have it throw an error and not upload anything at all, how to accomplish that? ___ Here's my contact form code: if($input->post->submit) { if(processContactForm($config, $pages)) { $session->redirect($pages->get("/contact/thanks/")->url); } else { $session->redirect($pages->get("/contact/error/")->url); } here's the function to upload (credits to @ryan) function processContactForm ($config, $pages) { $addedfile = _x('added file', 'contact form'); $input = wire('input'); $sanitizer = wire('sanitizer'); // Set a temporary upload folder where the files are stored during form processing // RC: precede temp dir with a period to ensure it remains non-web accessible $upload_path = $config->paths->assets . "files/temp/"; // RC: create temp path if it isn't there already if(!is_dir($upload_path)) { if(!wireMkdir($upload_path)) throw new WireException("No upload path"); } // New wire upload $user_file = new WireUpload('fileToUpload'); // References name of HTML form field $user_file->setMaxFiles(0); $user_file->setMaxFileSize(20000000); // 20MB $user_file->setOverwrite(false); $user_file->setDestinationPath($upload_path); $user_file->setValidExtensions(array('jpg', 'jpeg', 'png', 'gif', 'pdf', 'tiff', 'zip')); // execute upload and check for errors $files = $user_file->execute(); // RC: use count($files) as your decision whether to proceed not not, rather than getErrors() if(!count($files)) { return false; } // trying to count the number of uploaded files and return false to not upload at all if(count($user_file) > 20) { $user_file->error(_x('too many files!', 'contact form')); return false; } // Save in the ProcessWire page tree; map submission to the template fields $np = new Page(); // create new page object $np->template = "user"; $np->parent = $pages->get("title=userinputs"); $np->status(['hidden']); // RC: for safety, only add user uploaded files to an unpublished page, for later approval // RC: also ensure that using v2.3+, and $config->pagefileSecure=true; in your /site/config.php $np->addStatus(Page::statusUnpublished); if ($input->post->givenname != '') { $np->given_name = $sanitizer->text($input->post->givenname); } else { $np->given_name = 'idle'; } if ($input->post->familyname != '') { $np->family_name = $sanitizer->text($input->post->familyname); } else { $np->family_name = 'idle'; } $np->title = $np->family_name.' '.$np->given_name; // 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->name = $np->title; $np->save(); // Run photo upload foreach($files as $filename) { $pathname = $upload_path . $filename; $np->images->add($pathname); $np->message("$filename"); unlink($pathname); } // save page again $np->save(); return true; } and lastly, here's my success.php template: foreach($notices as $notice) { $class = $notice instanceof NoticeError ? "error" : "message"; echo "<p class='$class'>$notice->text</p>"; } $session->removeNotices(); Thanks for any hints!
  2. it doesn't know $page or $pages either…
  3. thanks! I wonder though why the ->type-> part is not in the API doc https://processwire.com/api/ref/fieldtype-options/get-options/ because without it, doesn't work
  4. namespace ProcessWire; function myfunction() { echo $config->paths->assets; // Notice: Undefined variable: config (…) } can't access the API inside a custom function. Didn't have that problem before. This seems like a basic setting. What could be the reason?
  5. how do I return all the options of an option field? I have an option field on the children pages and need to list them. The API-documentation says as follows… $items = $fieldtypeOptions->getOptions($field); but it doesn't work. Also unclear if $fieldtypeOptions is to be used as is or would that be replaced with my field? It's not apparent if you're not a pro, the API documentation lacks examples or explanations as usual.
  6. It was a stupid typo from my side, I found out using the console. I kinda got it to work or at least use the styles I add to mystyles.js. Now I'm trying to build a uk-accordion using the styles which is not that simple after all, not to mention for the client. I added these three styles: { name: 'uk-accordion', element: 'ul', attributes: { 'uk-accordion': 'collapsible: true' } }, { name: 'uk-acc-title', element: 'a', attributes: { 'class': 'uk-accordion-title' } }, { name: 'uk-acc-content', element: 'div', attributes: { 'class': 'uk-accordion-content' } } Also very important, as you mentioned, you need to first apply the appropriate html tags to the elements you want to add the styles to, otherwise the styles won't appear. So for the <a> element I first need to make it a link with href="#" (not too complicated, I think the client can handle that). For the content no need to add a tag. And for the <ul>, you guessed it, turn it into an unordered list first. Tried that in different orders, but either way, adding the uk-accordion style to the <ul> element always puts the <a> element after or inside the <div> or turns both elements into seprate <li> elements which is not how it should be thus it doesn't work. Can you think of a way to just apply the ul-style to the list and it adds the other styles to its children accordingly? Thanks for your help.
  7. yes that describes my problem exactly. I'm using a CKEditor body inside a repeater field. I read the other threads you mentioned and the GitHub issue. Any update on this issue or should I rethink the entire approach?
  8. thanks, I knew it was possible somehow cause I've seen and done it before, works fine.
  9. I'm trying to add an uikit accordion to the styles-list of a CKEditor-body. I understand I need to add a row to the file mystyles:/site/modules/InputfieldCKEditor/mystyles.js so I tried: { name: 'Accordion', element: 'ul', attributes: { 'uk-accordion' } } and also { name: 'Accordion', element: 'ul', attributes: { 'class', 'uk-accordion' } } but both don't work. It just breaks the styles-dropdown and no styles are shown at all. I'm really not doing many changes at all, don't know how this can fail so soon in the process, haven't even got to my more sophisticated requirements, which is achieving a markup like <li> <a class="uk-accordion-title" href="#"></a> <div class="uk-accordion-content"></div> </li> inside the <ul uk-accordion> Using Mac, tried Chrome and Safari, cleared cache etc. of course. Thanks for help!
  10. I have a bilingual site. I want home to also include /en/ at the end, thus to be www.example.com/en/ (english being the default language). Is that doable?
  11. I'm used to use _x('string', 'category') to fill all my language dependent needs with strings in templates. Now that I use a custom written php function that is included, this _x() function doesn't work anymore. #0 SITE/TEMPLATES/REFERENT.PHP (57): INCLUDE() #1 WIRE/CORE/TEMPLATEFILE.PHP (318): REQUIRE('/APPLICATIONS/M...') #2 WIRE/CORE/WIRE.PHP (394): TEMPLATEFILE->___RENDER() #3 WIRE/CORE/WIREHOOKS.PHP (823): WIRE->_CALLMETHOD('___RENDER', ARRAY) #4 WIRE/CORE/WIRE.PHP (465): WIREHOOKS->RUNHOOKS(OBJECT(TEMPLATEFILE), 'RENDER', ARRAY) #5 WIRE/MODULES/PAGERENDER.MODULE (536): WIRE->__CALL('RENDER', ARRAY) #6 WIRE/CORE/WIRE.PHP (397): PAGERENDER->___RENDERPAGE(OBJECT(HOOKEVENT)) #7 WIRE/CORE/WIREHOOKS.PHP (823): WIRE->_CAL (LINE 29 OF SITE/TEMPLATES/_FOOT.PHP) THIS ERROR MESSAGE WAS SHOWN BECAUSE: SITE IS IN DEBUG MODE. ($CONFIG->DEBUG = TRUE; => SITE/CONFIG.PHP). ERROR HAS BEEN LOGGED. any ideas?
  12. I have a php-script that should run after a form submission and in that php-script I would put a redirect to a success or error page respectively. so I add <action='/_myscript.php'> to the form. The script doesn't load though. What's the best practice for this? Where to put the script? root folder? site folder? template folder? and what would the path be because either way I try gives an 404 error or lack of access error. My guess is it absolutely needs to be/have a page?
  13. could someone walk me through what is required to upload files/images to some assets/files-folder from the frontend? All I can find online are general php-tutorials but no PW-tutorials and the PW-API-documentation is abstract to the point of complete confusion. I actually don't know what all these methods do exactly nor which ones are missing to make it work and how could I know? Here's what I did so far: if (isset($_POST['submit'])) { $path = $pages->get("id=1030"); $path->setOutputFormatting(false); $u = new WireUpload('fileToUpload'); $u->setMaxFiles(1); $u->setOverwrite(false); $u->setDestinationPath($path->images->path()); $u->setValidExtensions(array('jpg', 'jpeg', 'gif', 'png')); foreach($u->execute() as $filename) {$path->files->add($filename);} $u->save(); } <form action="<?php echo $page->url ;?>" method="post" enctype="multipart/form-data"> Select image to upload: <input type="file" name="fileToUpload" id="fileToUpload"> <input type="submit" value="Upload Image" name="submit"> </form> error: Exception: Method WireUpload::save does not exist or is not callable in this context many thanks
  14. I'm trying to install a multiple site installation as discussed here https://processwire.com/docs/more/multi-site-support/ Both sites are for the same client so I opted for option #1, different database, different web content, same PW installation. I already had worked on both sites separately, so now I just want to move one site to the root folder of the other PW installation where the other site folder sits. To my understanding, I need to change the config file to link to a different database and have different http-hosts. My question is, how do I get it to run on MAMP? In my htdocs folder I can only choose the main folder (in which both site-folders sit) and when I open that one it just shows me what's in site, not what is in site-2. thanks for help
  15. thanks for the quick answer and solution. I knew it had to be simple, works now.
  16. after migrating a site from localhost (MAMP) to live server, all the links are broken. I can only access the home-page (e.g. www.example.com), anything after a slash won't work (e.g. www.example.com/en/somepage), including /admin. It works perfectly on the local machine but not on the live server. What I did was to move the content from my local machine via ftp to the live server without previously installing a blank PW. Then I created a database, imported the database from my local machine and amended the database credentials (db-name, username, password) and also the httphosts-array. I had this issue before with another project, I think I fixed it by re-installing a blank PW-installation and only then replace the database with the one from my local machine. Is that the only way?
  17. how about "exact matches"? When I use the searchengine-module's demo-site, it seems to check for the exact match of each word of a search query in that very order. e.g. search queries (ignore the quotes): "scalability issues" returns 1 result "issues scalability" returns 0 results Some times you do not want exact matches and sometimes you do. When using Google, you soon figure out the use of quotes for an exact-match-query does the trick. Needless to say, that won't work here since the lack of quotes already returns exact matches. How to specify that on the frontend? Would there be a way to specify that by using/not using quotes? I want to avoid including yet another set of radio-buttons. thanks!
  18. just thought-showering here; would it be possible to replace the admin's entire cascade-style-dropdown-tree-layout (whatever you call it) to a table-layout instead or default to the finder-module? Might there be an admin-theme for that?
  19. I meant only for external links @dragan OK, thanks all for the suggestions and advice. I will reconsider now. In any case, good to know there's a module for this.
  20. Can I automatically add the attribute target="_blank" to all links created in a CKeditor body field?
  21. @kongondo agreed, my bad, thanks so far.
  22. so as mentioned above, I'm trying to use a combination of ProFields Table and ListerPro. I exported the table I created with the PageActionExportCSV within ListerPro to see how the data is structured so that I can then upload another list using the module ImportPagesCSV. But in the exported CSV file all the values of any column are in the same table cell of the same row instead of each in a new row, no matter what I do with Multi-value separators, CSV delimiters or CSV enclosure. Is that intended? If so, please explain why…
  23. Is there a way to simply select more images at once when adding them right inside the body-text? I can add images one by one no problem, so I would think that selecting more at once when adding them isn't too far fetched. Any more ideas on this issue? EDIT: The solution described above is rather for image galleries. I understand this can facilitate the upload procedure, upload to different galleries, repeated with a repeater-field and then included to the HTML with Hanna Code without the need of selecting images one by one anymore. This works fine when you know which images go above/below which text, but what if you want to upload all images at once to the page first (either to one field or more probably via FTP to the according /assets/file/page-folder/) and then, when entering/copy-pasting the text, select the images appropriately. If you have long articles (which is the case in my case) and up to 60 images, you still want to select more at once and not one-by-one. Also, I checked for CK-Editor-updates on Github. The current CKEditor-version on PW is 1.6.3, not to be confused with CKEditor4 or 5 version-numbering – I guess the module's version that comes with any new PW-installation is the newest anyway? What about addons/plugins from the ckeditor-page itself? ckeditor.com/cke4/addons. Personally couldn't find anything that meets my needs. Thanks for suggestions
  24. @kongondo no, I mean ImportPagesCSV.
  25. I installed ImportPagesCSV (thanks to Ryan) which seems to work like a charm, at least for pages – need to see for ProFields Table. The client has no problem with using that instead of SQL. Am I right to assume that this module is making proper use of the API? Upon upload, I hope that we'll be able to use ListerPro for bulk edits, even for ProFields Table and everything will be alright.
×
×
  • Create New...